// functions -------------------------------------------------------------------
function nowdate(){
  $("span#hktime").html("北京时间：<b>"+now.getDate()+ "日" +(now.getHours())+":"+(now.getMinutes())+":"+(now.getSeconds()+"</b>"));
  now.setTime(now.getTime() + 1000);
  setTimeout("nowdate()",1000);
}

function countdown(){
    if (timestap >= 0) {
      timediff = timestap;
      days = Math.floor(timediff / (60 * 60 * 24)); 
    	timediff -= days * (60 * 60 * 24);
    	hours = Math.floor(timediff / (60 * 60));
    	timediff -= hours * (60 * 60);
    	mins = Math.floor(timediff / (60));
    	timediff -= mins * (60);
    	secs = Math.floor(timediff);
        
      str = " || 距离截止下注时间还有 ";
      if (days > 0 ) str += "<b>" + days + "</b> 天 ";
      if (hours > 0) str += "<b>" + hours + "</b> 小时 ";
      if (mins > 0) str += "<b>" + mins + "</b> 分钟 ";
      str += "<b>" + secs + "</b> 秒 ";
      $("span#countdownstr").html(str);
      setTimeout("countdown()",1000)
      if($("select#reflashtime").val() != 0){$(this).chgMinData();} // reflash time
      timestap-=1;
      if (timestap==0) {
          $().getAjaxDataAuto(_playtype, __roundID);
	    }
    } else {
        $("span#countdownstr").html("<font color=red><b>已经截止下注 !</b></font>");
    }
}

// jQuery Functions ------------------------------------------------------------
$.fn.getAjaxDataAuto = function(playtype, _lotto_id){  
   //window.open('op.php?op=agent&fp=xmlBetTotal_3d&' + $("form#frmMenu").serialize());
 $.getJSON('op.php?op=agent&fp=xmlBetTotal_3d&' + $("form#frmMenu").serialize() ,function(ratedata){
      var dataLen = 0;
      var urlPre = "";
      var hrefStr = "";
      
      if(ratedata.errormsg != undefined){
        $("div#errormsg").addClass("error").text("No Rate data");
      }else{
          if( myGlobalVal.jsFuname ){
           if(myGlobalVal.simple){ // 简易版
            switch(playtype){
              case 'r1': show_r1_n5s(_lotto_id, playtype, ratedata, _myHeader); break; // 双面盘&龙虎和
              case 'r1p': show_r1p_n5s(_lotto_id, playtype, ratedata, _myHeader); break; // 一字盘势
              case 'r1o': show_r1os(_lotto_id, playtype, ratedata, _myHeader); break; // 跨度
            }
           }
           else{                         
            switch(playtype){
              	case 'r1': show_r1_n5(_lotto_id, playtype, ratedata, _myHeader); break;
				case 'r1p': show_r1p_n5(_lotto_id, playtype, ratedata, _myHeader); break;
                case 'r2': show_r2_n5(_lotto_id, playtype, ratedata, _myHeader); break;
                case 'nn': show_nn(_lotto_id, playtype, ratedata, _myHeader); break;
				case 'sh': show_sh(_lotto_id, playtype, ratedata, _myHeader); break;
            }
           }
          }else{
            switch(playtype){
            case 'r1': show_r1(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r2f': show_2face_n5(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r1p': show_r1p(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r2p': show_r2p(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r2': show_r2(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r2a': show_r2a(_lotto_id, playtype, ratedata, _myHeader2); break;
            case 'r3p': show_r3p(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r3': show_r3(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r3a': show_r3a(_lotto_id, playtype, ratedata, _myHeader2); break;
            case 'g3': show_g3(_lotto_id, playtype, ratedata, _myHeader, true); break;
            case 'g6': show_g3(_lotto_id, playtype, ratedata, _myHeader, false); break;
            case 'rcmp': show_r3p(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r1pass': show_r1pass(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r1bs': show_r1bs(_lotto_id, playtype, ratedata, _myHeader2); break;
            case 'r1o': show_r1o(_lotto_id, playtype, ratedata, _myHeader2); break;
            case 'r1all': return false; break;
            }
          }
          
          // set url
          $("span.span3da").click(function(){ $(this).setSpanAUrl(); });
          
          // set Btn Mim AND Plus
          $("#myDivTbl table td>input[class^=btn]").click(function(){
            $(this).setBtnMPUrl();
          });
          
          $("tbody th[rowspan>1]>input[class^=btn]").add("th.titleTypeBtnClick>input[class^=btn]")
          .click(function(){$(this).titleTypeBtnClick(myGlobalVal.jsFuname, playtype);});
          
          // 可按号码快选之玩法
          var curPointStr = ",r2p,r2,r3p,r3,rcmp,";
          var playtypeTemp = "," + playtype + ",";
          if(curPointStr.indexOf(playtypeTemp) > -1){
             $("th.td6").css("cursor", "pointer").click(function(){
              var strTemp = $("input#iptQuick01Val").val();
              var addStr = $(this).text(); 
              if(strTemp == ""){ $("input#iptQuick01Val").val(addStr); }
              else{     
                var srcStrTemp = "," + strTemp + ",";
                var addStrTemp = "," + addStr + ",";
                if(srcStrTemp.indexOf(addStrTemp) < 0){ $("input#iptQuick01Val").val(strTemp + "," + addStr); }
              }  
              });
          }
          
          // show the menu bar for amount of each page
          $().showPgTotalAmount(ratedata.pgTotalAmountStr);

          // can change again
          $("form#frmMenu input").removeAttr("disabled");
          
          // change tr color
          //$().chgTrColor();
      }
  });
};

$.fn.chgMinData = function(){
  tempMin = parseInt($("span#reflashtimeMin").text());
  if(tempMin == 0){
    //$(this).getAjaxDataAuto();
    $("input#btnReflash").click();
    $("span#reflashtimeMin").text(myGlobalVal.reloadCK);
  }else if(!$("select#reflashtime").attr("disabled")){
    $("span#reflashtimeMin").text(tempMin - 1);
  }
};

$.fn.chgTitleColorBlue = function(){$(".td15").removeClass("td15").addClass("td3");};
$.fn.chgTitleColorGray = function(){$(".td3").removeClass("td3").addClass("td15");};


// show the total bar
$.fn.showPgTotalAmount = function(oArr){
  var oTemp = "";
  var sTnD = new Date();
  var sTn = Math.round(sTnD.getTime() / 1000);
  for(x in oArr){
    oTemp = $('span#spanPageAmount' + oArr[x].idx ); 
    oTemp.text(oArr[x].amu);
    if( (oArr[x].tn > 0) && ((sTn - oArr[x].tn) < 30) ){
      oTemp.css({"background-color":"#FFFF99"});
    }else{
      oTemp.css({"background-color":""});
    }
  }
};  
// show the n/m url link
$.fn.setSpanAUrl = function(){
  var myid = $(this).attr("id").substr(4);
  var betdataArr = myid.split("_");
  var dates = $("input:hidden#dates").val();
  var datee = $("input:hidden#datee").val();
  var gametype = $("input:hidden#gametype").val();
  var lid = $("input:hidden#lotto_id_3d").val();
  var showUrl = '?op=agent&fp=betlist_3d&noback=1&bettype='+betdataArr[0]+'&subid=' + betdataArr[1] + '&num='+ betdataArr[2]+"&dates="+dates+"&datee="+datee+"&gametype="+gametype+"&lid="+lid;  
  //window.open(showUrl,'_self','scrollbars=yes');
  var oObj = document.getElementById("divRateRecord");
  oObj.innerHTML = "<div class='bgClc_" + gametype + "' align=right><input type='button' value='&nbsp;X&nbsp;' onclick='javascript:closeDiv();' class='c4'></div><iframe src='" + showUrl + "' width='100%' height='100%'></iframe><br />"; 
  oObj.className = "showRateRecord";
};

// for subdiary
$.fn.setBtnMPUrl = function(){
  var myid = $(this).attr("id").substr(3); 
  var betdataArr = myid.split("_");
  var addVal = $("#divBtnAddVal span.btnchoiced").text() - 0;
  $("tbody#tbdr"+betdataArr[0]+">tr>td>input[class^=btn]").attr("disabled","disabled");
  $("form#frmMenu input#actionBettype").val(betdataArr[0] + '_' + betdataArr[1]);
  $("form#frmMenu input#actionNum").val(betdataArr[2]);
  $("form#frmMenu input#actionMP").val($(this).attr("id").substr(0,1));
  $("form#frmMenu input#addVal").val(addVal);
  $("form#frmMenu input#method").val("0");
  var actionUrl = '?op=subsidary&fp=xmlSetRateS_3d&'+ $("form#frmMenu").serialize();
  $.ajax({
    type: 'POST',
    url: '?op=subsidary&fp=xmlSetRateS_3d',
    dataType: 'json',
    data: $("form#frmMenu").serialize(),
    success: function(rdata){
      if(rdata.msg == "OK"){    
         $("form#frmMenu input#btnReflash").click();
      }
    }
  });
   //window.open(actionUrl,'_blank');
};


// update rate
$.fn.setRateByXML = function(){
  $.ajax({
    type: 'POST',
    url: '?op=subsidary&fp=xmlSetRateS_3d',
    dataType: 'json',
    data: $("form#frmMenu").serialize(),
    success: function(rdata){
      if(rdata.msg=="OK"){
        $("form#frmMenu input#btnReflash").click();
      }else{
        alert('error');
      }
    }
  });
};


// set the quick change rate by bettype for all numbers
$.fn.titleTypeBtnClick = function(jsFuname, playtype){
    var myIdArr = $(this).parent("th").attr("id").split('_');
    if(myIdArr.length != 3){ return false; }
    else{
      var myId = myIdArr[1] + "_" + myIdArr[2];
      var bettype = myIdArr[1];
    }
    var actionNum = "";
    switch(playtype){
      case 'r1': actionNum = "0,1,2,3,4,5,6,7,8,9"; break;
      case 'r1p': actionNum = "0,1,2,3,4,5,6,7,8,9"; break;
      case 'r2a':
        var bettypeStr = ',' + bettype + ',';
        var betStr = ",36,37,38,";
        var betStr2 = ",39,40,41,";
        if(betStr.indexOf(bettypeStr) > -1){ actionNum = "4,5,6,7,8,9,10,11,12,13,14"; }
        else if(betStr2.indexOf(bettypeStr) > -1){ actionNum = "0,1,2,3,4,5,6,7,8,9"; } 
        break;
      case 'r3a':
        if(bettype == '42'){ actionNum = "6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21"; }
        else if(bettype == '43'){ actionNum = "0,1,2,3,4,5,6,7,8,9"; }
        break;
      case 'g3': actionNum = "0,1,2,3,4,5,6,7,8,9"; break;
      case 'g6': actionNum = "0,1,2,3,4,5,6,7,8,9"; break;
      case 'r1bs': actionNum = "0,1,2,3,4,5,6,7,8,9"; break;
      case 'r1o': actionNum = "0,1,2,3,4,5,6,7,8,9"; break;
      default : return false;
    }
    mp = $(this).attr("class").substr(3,1);
    $("form#frmMenu input#actionNum").val(actionNum);
    $("form#frmMenu input#actionBettype").val(myId);
    $("form#frmMenu input#actionMP").val(mp);
    $("form#frmMenu input#addType").val("1");
    $("form#frmMenu input#method").val("4");
    $().setRateByXML();
  };

$.fn.addThreeNum = function(chkStr){
  var reVal =  chkStr.substr(0,1) - 0;
  reVal += chkStr.substr(1,1) - 0;
  reVal += chkStr.substr(2,1) - 0;
  return reVal;
};

// -----------------------------------------------------------------------------
// print table functions
// -----------------------------------------------------------------------------
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @return String 表格字串
// 一字组合、佰定位、拾定位、个定位 都用此 function
function crt_0To9(rdata, rtotaldata, rnum, bettype, subBettype, sTitle){
  var str = "";
  var str2 = "";
  var i = 0;
  var j = 0;
  var oObj = 0;
  var setQuickUrl = " id='url_" +  bettype + "_" + subBettype + "'";
  str += "<tr class=td2 align=center id=thr" + rnum + "><th class='td6 bigBottom' rowspan=2 " + setQuickUrl  + " ><input type=button class=btnmin value='-' />" + sTitle + "<input type=button class=btnplus value='&Phi;' /></th>";
  str += "<th class='span3dall bigBottom' align=center rowspan=2>" + rtotaldata.amount + "</th></th>";
  str2 += "<tr class='td2 bigBottom' align=center>";
  for(j = 0; j < 10; j = j + 2){
    i = j;
    oObj = rdata[i];
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'";
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    str += "<th class=td6 align=center>" + oObj.numbers + "</th>";
    str += "<td class='" + oObj.bgclass + "'  align=center><input type=button class=btnmin value='-' id=m" + setBtnId + " />" + oObj.rate + "<input type=button class=btnplus value='&Phi;' id=p" + setBtnId + " />";
    str += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span></td><td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
    
    i = j + 1;
    oObj = rdata[i];
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'";
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    str2 += "<th class=td6 align=center>" + oObj.numbers + "</th>";
    str2 += "<td class='" + oObj.bgclass + "'  align=center><input type=button class=btnmin value='-' id=m" + setBtnId + " />" + oObj.rate + "<input type=button class=btnplus value='&Phi;' id=p" + setBtnId + " />";
    str2 += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span></td><td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
  }
  if(myGlobalVal.simple){
    str += "</tr>";
    str2 += "</tr>";
  }
  else{
    str += "<td></td><td></td><td></td></tr>";
    str2 += "<td></td><td></td><td></td></tr>";
  }
  
  return (str + str2);
}
function crt_0To5(rdata, rtotaldata, rnum, bettype, subBettype, sTitle){
  var str = "";
  var oObj = 0;
  var arr=new Array("豹子","顺子","对子","半顺","杂六");
  var setQuickUrl = " id='url_" +  bettype + "_" + subBettype + "'";
  str += "<tr class=td2 align=center id=thr" + rnum + "><th class='td6 bigBottom' " + setQuickUrl  + " >" + sTitle + "</th>";
  str += "<th class='span3dall bigBottom' align=center>" + rtotaldata.amount + "</th>";
  for(i = 0; i < rdata.length; i++){
    oObj = rdata[i];
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'";
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    str += "<th class='td6 bigBottom' align=center>" + arr[oObj.numbers] + "</th>";
    str += "<td class='" + oObj.bgclass + " bigBottom'  align=center><input type=button class=btnmin value='-' id=m" + setBtnId + " />" + oObj.rate + "<input type=button class=btnplus value='&Phi;' id=p" + setBtnId + " />";
    str += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span></td><td class='bigBottom' align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
  }
  str += "</tr>";
  return (str);
}
function crt_0To99(rdata, rtotaldata, rnum, bettype, subBettype, sTitle,arr){
  var str = "";
  var oObj = 0;
  var setQuickUrl = " id='url_" +  bettype + "_" + subBettype + "'";
  var rowspan=(bettype==74?3:2);
  str += "<tr class=td2 align=center id=thr" + rnum + "><th rowspan="+rowspan+" class='td6 bigBottom' " + setQuickUrl  + " >" + sTitle + "</th>";
  str += "<th  rowspan="+rowspan+" class='span3dall bigBottom' align=center>" + rtotaldata.amount + "</th>";
  for(i = 0; i < rdata.length; i++){
    oObj = rdata[i];
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'";
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    str += "<th class='td6 bigBottom' align=center>" + arr[oObj.numbers] + "</th>";
    str += "<td class='" + oObj.bgclass + " bigBottom'  align=center><input type=button class=btnmin value='-' id=m" + setBtnId + " />" + oObj.rate + "<input type=button class=btnplus value='&Phi;' id=p" + setBtnId + " />";
    str += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span></td><td class='bigBottom' align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
  	if(i==4 || i==9) str+="</tr><tr>";
  }
  if(bettype==75) str+="<th class='bigBottom'></th><td class='bigBottom'></td><td class='bigBottom'></td>";
  str += "</tr>";
  return (str);
}

// 双面盘
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Array rtotaldata 总笔数与总下注额
// @param Array rnum tbody的ID
// @param Array bettype 玩法id, 例如一字组合传 0
// @param Array subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @param Array showTitleArr 玩法名称阵列
// @return String 表格字串
// --
// 佰定位-大小,单双,质合
// 拾定位-大小,单双,质合
// 个定位-大小,单双,质合
// 佰拾和数 , 佰个和数 , 拾个和数 – 单双
// 佰拾个和数 – 大小单双  
// 佰拾个和数尾数 OOO – 大小质合
function crt_2face_com(rdata, rtotaldata, rnum, bettype, subBettype, sTitle, showTitleArr){
  var winlostStr = "";
  var setSpanAUrl = "";
  var setBtnId = "";
  var idx = 0;          // 阵列index
  var tempI = 0;        // 1, 2 (大, 小)    
  var str = "";
  var strTitle = "";
  var oObj = "";
  var num = 0;
  var setBtnId = "";
  var nextI = -1;        // 可秀玩法
  var i = 0;
  var l = 0;
  var littletotal = 0;
  var classCount = 0;
  if(myGlobalVal.simple){ // 简易版
    if(bettype[0] == 5){ var nextMath = 3; }
    else{ var nextMath = 2; }
  }
  else{
    if(bettype[0] == 73){ var nextMath = 3; }
    else{ var nextMath = 2; }
  }
  for(i = 0, l = showTitleArr.length; i < l; i++ ){
    if(showTitleArr[i] == ""){ str += "<td></td><td></td><td></td>"; continue;} // 空白
    else{ nextI++; }
    tempI = nextI % nextMath;
    num = tempI + 1;
    idx = (nextI - tempI) / nextMath; 
    oObj = rdata[idx][tempI];
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green" ;                                         // 输赢的颜色
    setSpanAUrl = "class=span3da id='url_" +  bettype[idx] + "_" + subBettype[idx] + "_" + oObj.numbers + "'"; // 笔数与金额的连结
    setBtnId = "b_"+  bettype[idx] + "_" + subBettype[idx] + "_" + oObj.numbers;
    
    str += "<th class=td6>" + showTitleArr[i] + "</th>";
    str += "<td id='td_r" + bettype[idx] +  "_" + subBettype[idx] + "_" + num + "' class='" + oObj.bgclass + "'>";
    str += "<input type='button' class='btnmin' value='-' id='m" + setBtnId + "' />" + oObj.rate + "<input type='button' class='btnplus' id='p" + setBtnId + "' value='&Phi;' /><br />";
    str += "<span " + setSpanAUrl + " >" + oObj.totalnum + "/" + oObj.amount + "</span>";
    str += "</td>";  
    str += "<td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
    if(oObj.bgclass != "") classCount = "namount";                          
  }
  // count little total
  for(i = 0, l = rtotaldata.length; i < l; i++){
    littletotal += rtotaldata[i].amount - 0;
  }
  
  strTitle += "<tr class='td2 bigBottom' align=center><th class=td6>" + sTitle + "</th>";
  strTitle += "<th class='span3dall " + classCount + "'>" + littletotal + "</th>";
  
  return strTitle + str;

}

// 万千和数 – 单双  - (五码才有)
// 万佰和数 – 单双  - (五码才有)
// 万拾和数 – 单双  - (五码才有)
// 万个和数 – 单双  - (五码才有)
// 千佰和数 – 单双  - (五码才有)
// 千拾和数 – 单双  - (五码才有)
// 千个和数 – 单双  - (五码才有)
// 佰拾和数 – 单双  - (五码才有)
// 佰个和数 – 单双  - (五码才有)
// 拾个和数 – 单双  - (五码才有)
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @return String 表格字串
function crt_2face_a_S(rdata, rtotaldata, rnum, bettype, subBettype, sTitle){
  var str = "";
  var i = 0;
  var oObj = 0;
  var strArr = ['', '单', '双'];
  str += "<tr class=td2 align=center id=thr" + rnum + "><th class=td6>" + sTitle + "</th>";
  str += "<th class=span3dall align=center>" + rtotaldata.amount + "</th>";
  for(i = 0; i < 2; i++){
    oObj = rdata[i];
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'";
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    str += "<th class=td6 align=center>" + strArr[oObj.numbers] + "</th>";
    str += "<td class='" + oObj.bgclass + "'  align=center><input type=button class=btnmin value='-' id=m" + setBtnId + " />" + oObj.rate + "<input type=button class=btnplus value='&Phi;' id=p" + setBtnId + " />";
    str += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span></td><td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
  }
  str += "</tr>";
  return str;
}

// ※ 二字定位 - (三码才有)
// 	佰拾 – 00 ~ 99 - (三码才有)
// 	佰个 – 00 ~ 99 - (三码才有)
// 	拾个 – 00 ~ 99 - (三码才有)
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @param String iNumTr tr列数
// @return String 表格字串
function crt_2p(rdata, rtotaldata, rnum, bettype, subBettype, sTitle, iNumTr){
  var str = "";
  var winlostStr = "";
  var setSpanAUrl = "";
  var setBtnId = "";
  var htmlTemp = '<tr class="td2" align="right">';
  var htmlTitle = '<th>号码</th><th>笔数</th><th>金额</th><th>输赢</th><th>补货</th><th>赔率</th><th>操盘</th>';
  var trArr = new Array();
  var idx = 0;
  var dataLen = rdata.length;
  var i = 0;                
  for(i = 0; i < iNumTr; i++){ trArr[i] = '';} 
  var oObj = 0;              
            
  str += '<caption class="td0 bgClc_' + myGlobalVal.gametype  + '">' + sTitle + '</caption>';
  str += '<thead><tr class="td15">' +  htmlTitle + htmlTitle + htmlTitle + htmlTitle + htmlTitle + '</tr></thead>';
  str += '<tbody>';
  for(i = 0; i < dataLen; i++){
    idx = i % iNumTr;
    oObj = rdata[i];
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'"; // 笔数与金额的连结
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    trArr[idx] += "<th class=td6 align=center>" + oObj.numbers + "</th>";
    trArr[idx] += "<td>" + oObj.totalnum + "</td>"; 
    trArr[idx] += "<td class='" + oObj.bgclass + "'><span " + setSpanAUrl + ">" + oObj.amount + "</span></td>";
    trArr[idx] += "<td nowrap class='jsbo'><font color=" + winlostStr + ">" + oObj.winlost + "</font></td><td>&nbsp;</td>";
    trArr[idx] += "<td class='rate_th2'>" + oObj.rate + "</td>";
    trArr[idx] += "<td align=center><input type=button class=btnmin value='-' id=m" + setBtnId + " />&nbsp;<input type=button class=btnplus value='&Phi;' id=p" + setBtnId + " /></td>";
  }
  str += htmlTemp + trArr.join('</tr><tr class=td2 align=right>') + '</tr>'; 
  return str;
}

// ※ 二字和数 - (三码才有)
// 	佰拾和数 – 0 ~ 18 - (三码才有)
// 	佰个和数 – 0 ~ 18 - (三码才有)
// 	拾个和数 – 0 ~ 18 - (三码才有)
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @return String 表格字串
function crt_2p_a_0To18(rdata, rtotaldata, rnum, bettype, subBettype, sTitle){
  var str = "";
  var i = 0;
  var winlostStr = "";
  var setSpanAUrl = "";
  var setBtnId = "";
  var oObj = 0;
  var setQuickUrl = " id='url_" +  bettype + "_" + subBettype + "' class='titleTypeBtnClick'";
  var showNum = "";
  str += "<tr class=td2 align=center id=thr" + rnum + "><th class=td6 rowspan=2 " + setQuickUrl + "><input type=button class=btnmin value='-' />" + sTitle + "<input type=button class=btnplus value='&Phi;' /></th>";
  str += "<th class=span3dall align=center rowspan=2>" + rtotaldata.amount + "</th></th>";
   
  for(i = 0; i < 11; i++){
    oObj = rdata[i];
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'"; // 笔数与金额的连结
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    if(i == 5){ str += "<td></td><td></td><td></td></tr><tr class=td2 align=center>" ;}
    if(oObj.numbers < 5) {showNum = "0~4";}
    else if(oObj.numbers > 13) {showNum = "14~18";}
    else {showNum = oObj.numbers; } 
    str += "<th class=td6 align=center>" + showNum + "</th>";
    str += "<td class='" + oObj.bgclass + "'  align=center><input type=button class=btnmin value='-' id=m" + setBtnId + " />" + oObj.rate + "<input type=button class=btnplus value='&Phi;' id=p" + setBtnId + " />";
    str += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span></td><td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
  }
  str += "</tr>";
  return str;
}

// ※ 二字和数
// 	佰拾和数尾数 – 0尾 ~ 9尾 - (三码才有)
// 	佰个和数尾数 – 0尾 ~ 9尾 - (三码才有)
//   拾个和数尾数 – 0尾 ~ 9尾 - (三码才有)
// ※ 三字和数
//   佰拾个和数尾数OOO 0~9 - (三码才有)
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @param String sNumStr 号码尾字
// @return String 表格字串
function crt_a_0To9(rdata, rtotaldata, rnum, bettype, subBettype, sTitle, sNumStr){
  var str = "";
  var winlostStr = "";
  var setSpanAUrl = "";
  var setBtnId = "";
  var setQuickUrl = " id='url_" +  bettype + "_" + subBettype + "'";
  var i = 0;
  var oObj = 0;
  str += "<tr class='td2' align=center id=thr" + rnum + "><th class=td6 rowspan=2 " + setQuickUrl + "><input type=button class=btnmin value='-' />" + sTitle + "<input type=button class=btnplus value='&Phi;' /></th>";
  str += "<th class=span3dall align=center rowspan=2>" + rtotaldata.amount + "</th></th>";
   
  for(i = 0; i < 10; i++){
    oObj = rdata[i]; 
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'"; // 笔数与金额的连结
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    if(i == 5){ str += "<td></td><td></td><td></td></tr><tr class=td2 align=center>" ;}
    
    str += "<th class=td6 align=center>" + oObj.numbers + sNumStr + "</th>";
    str += "<td class='" + oObj.bgclass + "'  align=center><input type=button class=btnmin value='-' id=m" + setBtnId + " />" + oObj.rate + "<input type=button class=btnplus value='&Phi;' id=p" + setBtnId + " />";
    str += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span></td><td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
    
  }
  str += "<td></td><td></td><td></td></tr>";
  return str;


}

// ※ 三字和数
// 	百拾个和数OOO  0~27  - (三码才有)
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @return String 表格字串
function crt_3_a(rdata, rtotaldata, rnum, bettype, subBettype, sTitle){
  var str = "";
  var i = 0;
  var winlostStr = "";
  var setSpanAUrl = "";
  var setBtnId = "";
  var preNum = "";
  var setQuickUrl = " id='url_" +  bettype + "_" + subBettype + "'";
  var oObj = 0;
  str += "<tr class=td2 align=center id=thr" + rnum + "><th class=td6 rowspan=3 "+ setQuickUrl +"><input type=button class=btnmin value='-' />" + sTitle + "<input type=button class=btnplus value='&Phi;' /></th>";
  str += "<th class=span3dall align=center rowspan=3>" + rtotaldata.amount + "</th></th>";
   
  for(i = 0; i < 16; i++){
    oObj = rdata[i];
    if(i > 0){preNum = oObj.numbers;}
    else { preNum = "0~6"; }
    if(i > 14){ preNum = "21~27"; }

    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'"; // 笔数与金额的连结
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    if(i > 0 && (i % 6 == 0)){ str += "</tr><tr class=td2 align=center>" ;}
    
    str += "<th class=td6 align=center>" + preNum + "</th>";
    str += "<td class='" + oObj.bgclass + "'  align=center><input type=button class=btnmin value='-' id=m" + setBtnId + " />" + oObj.rate + "<input type=button class=btnplus value='&Phi;' id=p" + setBtnId + " />";
    str += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span></td><td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
    
  }
  str += "<td></td><td></td><td></td><td></td><td></td><td></td></tr>";
  return str;

}


// ※ 组选三
// 	前三 – 5,6,7,8,9
// 	中三 – 5,6,7,8,9
// 	后三 – 5,6,7,8,9
// ※ 组选六
// 	前三 – 4,5,6,7,8
// 	中三 – 4,5,6,7,8
// 	后三 – 4,5,6,7,8
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @return String 表格字串
function crt_g(rdata, rtotaldata, rnum, bettype, subBettype, sTitle){
  var str = "";
  var dataLen = rdata.length;
  var i = 0; 
  var oObj = 0;
  var setBtnId = "";
  var setSpanAUrl = "";
  str += "<table class='tblMy3D' width='100%'><thead><tr class='td15'><th>号码</th><th>笔数</th><th>金额</th><th>赔率</th><th>操盘</th></tr></thead>";
  str += "<tbody>";
  if(bettype == 29){    
    for(i = 0; i < dataLen ; i++){
      oObj = rdata[i];
      setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
      setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'"; // 笔数与金额的连结
      str += "<tr class='td2' align='right'><th class='td6' align='center'>全包</th><td>" + oObj.totalnum + "</td>";
      str += "<td class='" + oObj.bgclass + "'><span" + setSpanAUrl + ">" + oObj.amount + "</span></td>";
      str += "<td class='rate_th2'>" + oObj.rate + "</td>";
      str += "<td align='center'><input type='button' class='btnmin' value='-' id='m" + setBtnId + "' />&nbsp;<input type='button' class='btnplus' value='&Phi;' id='p" + setBtnId + "' /></td></tr>";
    }   
  }else{
    for(i = 0; i < dataLen ; i++){
      oObj = rdata[i];      
      setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
      setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'"; // 笔数与金额的连结                    
      str += "<tr class='td2' align='right'><th class='td6' align='center'>" + oObj.numbers + "</th><td>" + oObj.totalnum + "</td>";
      str += "<td class='" + oObj.bgclass + "'><span" + setSpanAUrl + ">" + oObj.amount + "</span></td>";
      str += "<td class='rate_th2'>" + oObj.rate + "</td>";
      str += "<td align='center'><input type='button' class='btnmin' value='-' id='m" + setBtnId + "' />&nbsp;<input type='button' class='btnplus' value='&Phi;' id='p" + setBtnId + "' /></td></tr>";
    }   
  
  }
  str += "</tbody>";
  str += "<tfoot align='right'><tr class='td6' align='right'><th class='td0 bgClc_" + myGlobalVal.gametype + "'>合计</th><td>" + rtotaldata.totalnum + "</td><td>" + rtotaldata.amount + "</td><td>--</td><td>--</td></tr></tfoot>";
  str += "</table>";
  return str;
}

// ※ 一字过关
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @return String 表格字串
function crt_1pass(rdata, rtotaldata, rnum, bettype, subBettype, sTitle){
  var titleArr = [['大', '小'], ['单', '双'], ['质', '合']];
  var i = 0;
  var j = 0;
  var k = 0;
  var strTbl = "";
  var winlostStr = "";
  var setBtnId = "";
  var setSpanAUrl = "";
  for(i = 0; i < 3; i++ ){
    strTbl += "<tr>";
    for(j = 0; j < 3; j++){
      k = (6 * j) + (i * 2);
      setBtnId = "b_"+  bettype + "_" + subBettype + "_" + rdata[k].numbers;
      setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + rdata[k].numbers + "'"; // 笔数与金额的连结

      winlostStr = ( rdata[k].winlost < 0 ) ? "#FF00FF" : "green";
      strTbl += "<th class='td6'>" + titleArr[i][0] + "</th>"; // "<td class='betnum' id='td_r46_" + k + "'>&nbsp;</td><td id='td_wl_r46_" + k + "' align='right'>&nbsp;</td>";
      strTbl += "<td class='" + rdata[k].bgclass + "'  align=center><input type=button class=btnmin value='-' id=m" + setBtnId + " />" + rdata[k].rate + "<input type=button class=btnplus value='&Phi;' id=p" + setBtnId + " />";
      strTbl += "<br /><span " + setSpanAUrl + ">" + rdata[k].totalnum + "/" + rdata[k].amount + "</span></td><td align=right><font color=" + winlostStr + ">" + rdata[k].winlost + "</font></td>";
      
      k += 1;
      setBtnId = "b_"+  bettype + "_" + subBettype + "_" + rdata[k].numbers;
      setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + rdata[k].numbers + "'"; // 笔数与金额的连结

      winlostStr = ( rdata[k].winlost < 0 ) ? "#FF00FF" : "green";
      strTbl += "<th class='td6'>" + titleArr[i][1] + "</th>"; // "<td class='betnum' id='td_r46_" + k + "'>&nbsp;</td><td id='td_wl_r46_" + k + "' align='right'>&nbsp;</td>";
      strTbl += "<td class='" + rdata[k].bgclass + "'  align=center><input type=button class=btnmin value='-' id=m" + setBtnId + " />" + rdata[k].rate + "<input type=button class=btnplus value='&Phi;' id=p" + setBtnId + " />";
      strTbl += "<br /><span " + setSpanAUrl + ">" + rdata[k].totalnum + "/" + rdata[k].amount + "</span></td><td align=right><font color=" + winlostStr + ">" + rdata[k].winlost + "</font></td>";
      
    }
    strTbl += "</tr>";
  }
  return strTbl;
}

// ※ 其他 - 豹子 顺子 对子 半顺 杂六 - (三码才有)
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @return String 表格字串
function crt_o(rdata, rtotaldata, rnum, bettype, subBettype, sTitle){

  var str = "";
  var i = 0;
  var winlostStr = "";
  var setSpanAUrl = "";
  var setBtnId = "";
  var titleArr = ["豹子", "顺子", "对子", "半顺", "杂六"];
  var oObj = "";
  str += "<tr class=td2 align=center id=thr" + rnum + "><th class=td6>"+ sTitle +"</th>";
  if(myGlobalVal.simple){str += "<th class=span3dall align=center>" + rtotaldata.amount + "</th></th>";}
  else{str += "<th class=span3dall align=center>" + rtotaldata[0].amount + "</th></th>";}
   
  for(i = 0; i < 5; i++){
    if(myGlobalVal.simple){oObj = rdata[i];}
    else{oObj = rdata[i][0];}
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    if(myGlobalVal.simple){
      setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'"; // 笔数与金额的连结
      setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    }
    else{
      setSpanAUrl = " class=span3da id='url_" +  bettype[i] + "_" + subBettype[i] + "_" + oObj.numbers + "'"; // 笔数与金额的连结
      setBtnId = "b_"+  bettype[i] + "_" + subBettype[i] + "_" + oObj.numbers;
    }
    str += "<th class=td6 align=center>" + titleArr[i] + "</th>";
    str += "<td class='" + oObj.bgclass + "'  align=center><input type=button class=btnmin value='-' id=m" + setBtnId + " />" + oObj.rate + "<input type=button class=btnplus value='&Phi;' id=p" + setBtnId + " />";
    str += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span></td><td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
    
  }
  if(myGlobalVal.simple){str += "</tr>";}
  else{str += "<td></td><td></td><td></td></tr>";}
  return str;
}

// 增量 - 按钮 + -
function crt_divBtnAddVal(showAct){
  var str = "";
  var btnArr = [5, 4, 3, 2, 1, 0.5, 0.4, 0.3, 0.2, 0.1, 0.05, 0.02, 0.01,0.005,0.001];
  str += "<div id='divBtnAddVal'>";
  str += "<span class=btnchoice>";
  str += btnArr.join("</span><span class=btnchoice>"); 
  str += "</span>";
  if(showAct) { str += "　动作<input type='button' value='-' class='btnmin'><input type='button' value='&Phi;' class='btnplus'>"; }
  str += "</div>";
  return str;
}

// 增量 - 输入赔率值表单
function crt_spanChgAddType0(){
  var str = "";
  str += "<div id='spanChgAddType0'>请输入赔率值:<input type='text' value='' id='chgByValDir' size='3' /><input type='button' value='更改' id='btnChgByValDir' class='c3' /></div>";
  return str;
}

// 大单提示表格
function crt_chkhint(){
  var str = "";
  str += "<input type='checkbox' id='chkhint'><label for='chkhint'>大单视窗提示(不分玩法)</label>";
  str += "　<input type='checkbox' id='chksound'><label for='chksound'>大单音效提示</label>　　";
  if(myGlobalVal.btnSetConfFly){ str += "<input type='button' id='btnSetConfFly' value='启动走飞' disabled />"; }
  else{ str += "<input type='button' id='btnSetConfFly' value='启动走飞' />"; }
  return str;
}

// @param divType
// 1 快选 0 - 9
// 2 快选按钮  对对, 一般
// 3 快选按钮 豹子, 对对, 一般
function crt_divBtnQuick01(divType){
  var str = "";
  str += "<div id='divBtnQuick01'>快选";
           
  switch(divType){
    case 1:
      var btnArr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ];
      str += "<span class='btnchoice'>"
      str += btnArr.join("</span><span class='btnchoice'>");
      str += "</span>";
      str += "<input type='hidden' value='' id='iptQuick01Val' />";
              
      break;
      
    case 2:
      var btnArr = ['对对号码', '一般号码'];
      str += "<span class='btnchoice'>"
      str += btnArr.join("</span><span class='btnchoice'>");
      str += "</span>";
      str += "&nbsp;<input type='text' value='' id='iptQuick01Val' size='40' /><input type='button' id='btnClear' value='清除' onclick='javascript:ClearQuick01Val()'/>";
      break;
      
    case 3:
      var btnArr = ['豹子', '对对', '一般'];
      str += "<span class='btnchoice'>"
      str += btnArr.join("</span><span class='btnchoice'>");
      str += "</span>";
      str += "&nbsp;<input type='text' value='' id='iptQuick01Val' size='40' /><input type='button' id='btnClear' value='清除' onclick='javascript:ClearQuick01Val()'/>";
      break;
  }
  str += "</div>";
  return str;  

}

// 升降赔率、调整赔率选单
function crt_chgAddType(playtype){
  var str = "";
  str += "<select id='chgAddType' onchange='javascript:show_divBtnAddVal(this.value);'><option class='alert1' value='0_"+playtype+"'>调整赔率</option><option class='alert2' value='1_"+playtype+"'>升降赔率</option></select>";
  return str;
}

// 选单切换
function show_divBtnAddVal(vObj){
  var valArr = vObj.split("_");
  var val = valArr[0];
  var playtype = valArr[1]; 
  var str = "";     
  switch(val){
    case '0' :
      str = crt_spanChgAddType0();
      $('#divBtnQuickArea').html(str);
      break;
    case '1' :
      str = crt_divBtnAddVal(true);
      $('#divBtnQuickArea').html(str);
      break;
    default: return false;
  }
  $().setCookie('chgAddType3DCK',val);
  
  
          
  switch(playtype){
    case 'r2p':
    // + - 动作按钮 (根据快选号码)
    $("#divBtnAddVal input:button[class^=btn]").click(function(){
      var myVal = $("#divBtnQuick01 input#iptQuick01Val").val();
      var mp = "";
      var typeVal = "";
      if(myVal != ""){
        mp = $(this).attr("class").substr(3,1);
        typeVal = $("div#chgBtnGroup input[class=btnchoiced]").attr("id").substr(4);
        $("form#frmMenu input#actionNum").val(myVal);         // 资料转移
        $("form#frmMenu input#actionBettype").val(typeVal);   // 资料设定
        $("form#frmMenu input#actionMP").val(mp);             // 资料转移
        $("form#frmMenu input#addType").val("1");
        $("form#frmMenu input#method").val("2");
        $("form#frmMenu input#subid").val("0");
        $().setRateByXML(); // 更新赔率
      }else{
        alert('请先选择快选号码');
      }
    });
    
    // 更改 动作按钮 - addType1   
    $("#spanChgAddType0 input:button#btnChgByValDir").click(function(){
    
      var myVal = $("#divBtnQuick01 input#iptQuick01Val").val();
      var mp = "";
      var typeVal = "";
      var addTypeVal = "";
      if(myVal != ""){
        mp = "m";
        typeVal = $("div#chgBtnGroup input[class=btnchoiced]").attr("id").substr(4);
        addTypeVal = $("input#chgByValDir").val();
        if(addTypeVal != "" && addTypeVal > 1){
          $("form#frmMenu input#actionNum").val(myVal);         // 资料转移
          $("form#frmMenu input#actionBettype").val(typeVal);   // 资料设定
          $("form#frmMenu input#actionMP").val(mp);             // 资料转移
          $("form#frmMenu input#addType1Val").val(addTypeVal);  // 资料转移 - 要修改的值
          $("form#frmMenu input#addType").val("0");
          $("form#frmMenu input#method").val("1");
          var answer = confirm("确定要将 【" + $("div#chgBtnGroup input[class=btnchoiced]").val() + "】玩法之号码:\n"+myVal+"\n的赔率异动为【"+addTypeVal+"】吗?")
        	if(answer){                                                                              
        		$().setRateByXML(); // 更新赔率
        	}
        }else{
          alert('请先填入要异动赔率(大于1)');
        }
      }else{
        alert('请先选择快选号码');
      }
    });

    break;
    case 'r2':
       // + - 动作按钮 (根据快选号码)
      $("#divBtnAddVal input:button[class^=btn]").click(function(){
        var myVal = $("#divBtnQuick01 input#iptQuick01Val").val();
        var subid = $("form#frmMenu input#subid").val(); 
        var mp = "";
        var typeVal = "";
        if(myVal != ""){
          var actionBettype = "13" + "_" +$("form#frmMenu input#subid").val();
          mp = $(this).attr("class").substr(3,1);
          $("form#frmMenu input#actionNum").val(myVal);         // 资料转移
          $("form#frmMenu input#actionBettype").val(actionBettype); // 资料设定
          $("form#frmMenu input#actionMP").val(mp);             // 资料转移
          $("form#frmMenu input#addType").val("1");
          $("form#frmMenu input#method").val("2");
          $().setRateByXML(); // 更新赔率
        }else{
          alert('请先选择快选号码');
        }
      });
      
      // 更改 动作按钮 - addType1
      $("#spanChgAddType0 input:button#btnChgByValDir").click(function(){
        var myVal = $("#divBtnQuick01 input#iptQuick01Val").val();
        var mp = "";
        var typeVal = "";
        var addTypeVal = "";
        if(myVal != ""){
          mp = "m";
          addTypeVal = $("input#chgByValDir").val();
          var actionBettype = "13" + "_" +$("form#frmMenu input#subid").val();
          if(addTypeVal != "" && addTypeVal > 1){
            $("form#frmMenu input#actionNum").val(myVal);               // 资料转移
            $("form#frmMenu input#actionBettype").val(actionBettype);   // 资料设定
            $("form#frmMenu input#actionMP").val(mp);                   // 资料转移
            $("form#frmMenu input#addType1Val").val(addTypeVal);        // 资料转移 - 要修改的值  
            $("form#frmMenu input#addType").val("0");
            $("form#frmMenu input#method").val("1");
            var answer = confirm("确定要将 【二字不定位】玩法之号码:\n"+myVal+"\n的赔率异动为【"+addTypeVal+"】吗?")
          	if(answer){
          		$().setRateByXML(); // 更新赔率
          	}
          }else{
            alert('请先填入要异动赔率(大于1)');
          }
        }else{
          alert('请先选择快选号码');
        }
      });

      break;
      
    case 'r3p':
      // + - 动作按钮 (根据快选号码)
      $("#divBtnAddVal input:button[class^=btn]").click(function(){
        var myVal = $("#divBtnQuick01 input#iptQuick01Val").val();
        var mp = "";
        var typeVal = "";
        if(myVal != ""){ 
          mp = $(this).attr("class").substr(3,1);
          $("form#frmMenu input#actionNum").val(myVal);         // 资料转移
          $("form#frmMenu input#actionBettype").val("21");      // 资料设定
          $("form#frmMenu input#actionMP").val(mp);             // 资料转移
          $("form#frmMenu input#addType").val("1");
          $("form#frmMenu input#method").val("2");
          $().setRateByXML(); // 更新赔率
        }else{
          alert('请先选择快选号码');
        }
      }); 
      
      // 更改 动作按钮 - addType1
      $("#spanChgAddType0 input:button#btnChgByValDir").click(function(){
        var myVal = $("#divBtnQuick01 input#iptQuick01Val").val();
        var mp = "";
        var typeVal = "";     
        var addTypeVal = "";
        if(myVal != ""){
          addTypeVal = $("input#chgByValDir").val();
          mp = "m";
          if(addTypeVal != "" && addTypeVal > 1){
            $("form#frmMenu input#actionNum").val(myVal);         // 资料转移
            $("form#frmMenu input#actionBettype").val("21");      // 资料设定
            $("form#frmMenu input#actionMP").val(mp);             // 资料转移
            $("form#frmMenu input#addType1Val").val(addTypeVal);        // 资料转移 - 要修改的值
            $("form#frmMenu input#addType").val("0");
            $("form#frmMenu input#method").val("1");
            if(myVal == "NORMAL"){myVal="一般号吗"}
            var answer = confirm("确定要将 【三字定位(佰拾个定位)】玩法之号码:\n"+myVal+"\n的赔率异动为【"+addTypeVal+"】吗?")
          	if(answer){
          		$().setRateByXML(); // 更新赔率
          	}
          }else{
            alert('请先填入要异动赔率(大于1)');
          }
        }else{
          alert('请先选择快选号码');
        }
      }); 

      break;
    case 'r3':
      // + - 动作按钮 (根据快选号码)
      $("#divBtnAddVal input:button[class^=btn]").click(function(){
        var myVal = $("#divBtnQuick01 input#iptQuick01Val").val();
        var mp = "";
        var typeVal = "";
        if(myVal != ""){
          mp = $(this).attr("class").substr(3,1);
          var actionBettype = "20" + "_" +$("form#frmMenu input#subid").val();
          $("form#frmMenu input#actionNum").val(myVal);             // 资料转移
          $("form#frmMenu input#actionBettype").val(actionBettype); // 资料设定
          $("form#frmMenu input#actionMP").val(mp);                 // 资料转移
          $("form#frmMenu input#addType").val("1");
          $("form#frmMenu input#method").val("2");
          $().setRateByXML(); // 更新赔率
        }else{
          alert('请先选择快选号码');
        }
      });
      
      // 更改 动作按钮 - addType1
      $("#spanChgAddType0 input:button#btnChgByValDir").click(function(){
        var myVal = $("#divBtnQuick01 input#iptQuick01Val").val();
        var mp = "";
        var typeVal = "";
        var addTypeVal = "";
        if(myVal != ""){
          mp = "m";
          addTypeVal = $("input#chgByValDir").val();
          if(addTypeVal != "" && addTypeVal > 1){
            var actionBettype = "20" + "_" +$("form#frmMenu input#subid").val();
            $("form#frmMenu input#actionNum").val(myVal);         // 资料转移
            $("form#frmMenu input#actionBettype").val(actionBettype);      // 资料设定
            $("form#frmMenu input#actionMP").val(mp);             // 资料转移
            $("form#frmMenu input#addType1Val").val(addTypeVal);        // 资料转移 - 要修改的值  
            $("form#frmMenu input#addType").val("0");
            $("form#frmMenu input#method").val("1");
            var answer = confirm("确定要将 【三字组合(三字不定位)】玩法之号码:\n"+myVal+"\n的赔率异动为【"+addTypeVal+"】吗?")
          	if(answer){
          		$().setRateByXML(); // 更新赔率
          	}
          }else{
            alert('请先填入要异动赔率(大于1)');
          }
        }else{
          alert('请先选择快选号码');
        }
      });

      break;
    case 'rcmp':
      // + - 动作按钮 (根据快选号码)
      $("#divBtnAddVal input:button[class^=btn]").click(function(){
        var myVal = $("#divBtnQuick01 input#iptQuick01Val").val();
        var mp = "";
        var typeVal = "";
        if(myVal != ""){
          mp = $(this).attr("class").substr(3,1);
          $("form#frmMenu input#actionNum").val(myVal);         // 资料转移
          $("form#frmMenu input#actionBettype").val("35");      // 资料设定
          $("form#frmMenu input#actionMP").val(mp);             // 资料转移
          $("form#frmMenu input#addType").val("1");
          $("form#frmMenu input#method").val("2");
          $().setRateByXML(); // 更新赔率
        }else{
          alert('请先选择快选号码');
        }
      }); 
      
      // 更改 动作按钮 - addType1
      $("#spanChgAddType0 input:button#btnChgByValDir").click(function(){
        var myVal = $("#divBtnQuick01 input#iptQuick01Val").val();
        var mp = "";
        var typeVal = "";
        var addTypeVal = "";
        if(myVal != ""){
          addTypeVal = $("input#chgByValDir").val();
          mp = "m";
          if(addTypeVal != "" && addTypeVal > 1){
            $("form#frmMenu input#actionNum").val(myVal);         // 资料转移
            $("form#frmMenu input#actionBettype").val("35");      // 资料设定
            $("form#frmMenu input#actionMP").val(mp);             // 资料转移
            $("form#frmMenu input#addType1Val").val(addTypeVal);        // 资料转移 - 要修改的值
            if(myVal == "NORMAL"){myVal="一般号吗"}
            $("form#frmMenu input#addType").val("0");
            $("form#frmMenu input#method").val("1");
            var answer = confirm("确定要将 【复式组合】玩法之号码:\n"+myVal+"\n的赔率异动为【"+addTypeVal+"】吗?")
          	if(answer){
          		$().setRateByXML(); // 更新赔率
          	}
          }else{
            alert('请先填入要异动赔率(大于1)');
          }
        }else{
          alert('请先选择快选号码');
        }
      }); 
      break;
    default: ;
  }
  
 // button of add value -- over page
 $("#divBtnAddVal span").click(function(){
   var addVal = $(this).text();
   $("input#addVal").val(addVal);
   $("#divBtnAddVal span").removeClass("btnchoiced").addClass("btnchoice");
   $(this).addClass("btnchoiced");
   $().setCookie('btnAddVal3DCK' +playtype ,$(this).index());
 });
 
 var btnAddVal3DCK = $().getCookie('btnAddVal3DCK' + playtype,12);
 $("#divBtnAddVal span:eq(" + btnAddVal3DCK + ")").click();

}

// 组三、组六转值
function crt_rdoQuickPair(){
  var str = "";
  var i = 0;
  str += "<fieldset id='fldQuickPair' style='font-weight:bold;'>";
  str += "<input type='radio' name='rdoQuickPair' id='rdoQuickPair01' checked='checked' value='0' /><label for='rdoQuickPair01' class='blueblod'>组三转直</label>&nbsp;";
  str += "<input type='radio' name='rdoQuickPair' id='rdoQuickPair02' value='1' /><label for='rdoQuickPair02' class='blueblod'>组六转直</label>&nbsp;";
  str += "[<input type='checkbox' id='chkCheckAll' value='chkAll' />全选&nbsp;";
  for(i = 0; i < 10; i++){
    str += "<label><input type='checkbox' name='chkQuickPairNum[]' value='" + i + "' />" + i + "</label>&nbsp;";
  }
  
  str += "<label><input type='checkbox' name='chkQuickPairNum[]' value='10' />合单</label>&nbsp;";
  str += "<label><input type='checkbox' name='chkQuickPairNum[]' value='11' />合双</label>&nbsp;";
  str += "<label><input type='checkbox' name='chkQuickPairNum[]' value='12' />合大</label>&nbsp;";
  str += "<label><input type='checkbox' name='chkQuickPairNum[]' value='13' />合小</label>&nbsp;";
  str += "&nbsp;]&nbsp;勾选后请手动更新赔率(↑)";
  str += "</fieldset>";
  return str;    
}

              
// 补货计算
function crt_bo1(){
  var str = "";
  str += "补货赔率: <input name='bo1' id='bo1' value='42' size=3>　最大输值: <input name='bo2' id='bo2' value='-200000' size='8'>　<input type='button' value='补货计算' id='btnCountBo' /> 　　　　　　";
  return str;
}

// 切换前三后三中三按钮
function btnChgSubId(subid){
  $("form#frmMenu input#subid").val(subid);
  $("input#btnReflash").click();
}

// 产生前中后按钮
function crt_btnSubid(subid, mainTitle){
  var strTbl = "";
  var subTitle = ['后三', '中三', '前三']
  var subClass = 'colorBtnGray';
  strTbl += "<div>";
  for(i = 2; i > -1; i--){
    if(i == subid){subClass = 'c1'; }
    else{ subClass = 'colorBtnGray'; }
    strTbl += "<input type='button' onclick='javascript:btnChgSubId(" + i + ");' value='" + subTitle[i] + "◎" + mainTitle + "' class='" + subClass + "' />";
  }
  strTbl += "</div>";
  return strTbl;
  
}
// 清除
function ClearQuick01Val(){
  document.getElementById('iptQuick01Val').value='';
}

// 切换 bid
function chgBid(bid){
  var bidStr = bid.toString();
  $('form#frmMenu input#bid').val(bid);
  $("input#btnReflash").click();
}


// -----------------------------------------------------------------------------
// 玩法呼叫的function 
// -----------------------------------------------------------------------------
  
// 主盘势    
function show_r1(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += _myHeader;
  var rArr = "";
  var rArrA = "";
  var betArr = "";
  var showTitleArr = "";
  
  //	一字组合
  strTbl += crt_0To9(ratedata.r0_0, ratedata.r0_0total, "", 0, 0, '一字组合');
                       
  // 佰定位-大小,单双,质合
  showTitleArr = ['大', '小', '单', '双', '质', '合'];
  strTbl += crt_2face_com([ratedata.r4_0 , ratedata.r7_0 , ratedata.r10_0]
                        , [ratedata.r4_0total, ratedata.r7_0total, ratedata.r10_0total]
                        , "", [4, 7, 10], [0,0,0], '佰定位', showTitleArr);

  // 拾定位-大小,单双,质合
  strTbl += crt_2face_com([ratedata.r5_0, ratedata.r8_0, ratedata.r11_0]
                         , [ratedata.r5_0total, ratedata.r8_0total,ratedata.r11_0total]
                         , "", [5, 8, 11], [0,0,0], '拾定位', showTitleArr);
  
  // 个定位-大小,单双,质合
  strTbl += crt_2face_com([ratedata.r6_0, ratedata.r9_0, ratedata.r12_0]
                         , [ratedata.r6_0total, ratedata.r9_0total,ratedata.r12_0total]
                         , "", [6, 9, 12], [0,0,0], '个定位', showTitleArr);
  
  // 佰拾和数 , 佰个和数 , 拾个和数 – 单双
  showTitleArr = ['', '', '单', '双', '', ''];
  strTbl += crt_2face_com([ratedata.r17_0], [ratedata.r17_0total], "", [17], [0], '佰拾和数 OOX', showTitleArr);
  strTbl += crt_2face_com([ratedata.r18_0], [ratedata.r18_0total], "", [18], [0], '佰个和数 OXO', showTitleArr);
  strTbl += crt_2face_com([ratedata.r19_0], [ratedata.r19_0total], "", [19], [0], '拾个和数 XOO', showTitleArr);
  
  
  // 佰拾个和数 – 大小单双
  strTbl += crt_2face_com([ratedata.r22_0 , ratedata.r23_0]
                        , [ratedata.r22_0total, ratedata.r23_0total]
                        , "", [22, 23], [0, 0], '佰拾个和数 OOO', ['大', '小', '单', '双', '', '']);
  
  // 佰拾个和数尾数 OOO – 大小质合
  strTbl += crt_2face_com([ratedata.r44_0 , ratedata.r45_0]
                        , [ratedata.r44_0total, ratedata.r45_0total]
                        , "", [44, 45], [0, 0], '佰拾个和数尾数 OOO ', ['尾大', '尾小', '', '', '尾质', '尾合']);
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}


// 一字组合 - 五码
function show_r1_n5(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += _myHeader;
  
  //	全五字组合
  strTbl += crt_0To9(ratedata.r55_0, ratedata.r55_0total, "", 55, 0, '全五一字组合');
  
  // 一字组合 - 前中后
  strTbl += crt_0To9(ratedata.r0_2, ratedata.r0_2total, "", 0, 2, '前三一字组合');
  strTbl += crt_0To9(ratedata.r0_1, ratedata.r0_1total, "", 0, 1, '中三一字组合');
  strTbl += crt_0To9(ratedata.r0_0, ratedata.r0_0total, "", 0, 0, '后三一字组合');
  
  // N定位-大小,单双,质合
  var showTitleArr = ['大', '小', '单', '双', '质', '合'];
  var showTitleArr2 = ['总大', '总小', '总单', '总双', '', ''];
  var showTitleArr3 = ['龙', '虎', '和', '', '', ''];
  
  // 万定位-大小,单双,质合
  strTbl += crt_2face_com([ratedata.r56_0 , ratedata.r57_0 , ratedata.r58_0]
                        , [ratedata.r56_0total, ratedata.r57_0total, ratedata.r58_0total]
                        , "", [56, 57, 58], [0,0,0], '万定位OXXXX', showTitleArr);

  // 千定位-大小,单双,质合
  strTbl += crt_2face_com([ratedata.r59_0 , ratedata.r60_0 , ratedata.r61_0]
                        , [ratedata.r59_0total, ratedata.r60_0total, ratedata.r61_0total]
                        , "", [59, 60, 61], [0,0,0], '千定位XOXXX', showTitleArr);
  
  // 佰定位-大小,单双,质合
  strTbl += crt_2face_com([ratedata.r4_0 , ratedata.r7_0 , ratedata.r10_0]
                        , [ratedata.r4_0total, ratedata.r7_0total, ratedata.r10_0total]
                        , "", [4, 7, 10], [0,0,0], '佰定位XXOXX', showTitleArr);

  // 拾定位-大小,单双,质合
  strTbl += crt_2face_com([ratedata.r5_0, ratedata.r8_0, ratedata.r11_0]
                         , [ratedata.r5_0total, ratedata.r8_0total,ratedata.r11_0total]
                         , "", [5, 8, 11], [0,0,0], '拾定位XXXOX', showTitleArr);
  
  // 个定位-大小,单双,质合
  strTbl += crt_2face_com([ratedata.r6_0, ratedata.r9_0, ratedata.r12_0]
                         , [ratedata.r6_0total, ratedata.r9_0total,ratedata.r12_0total]
                         , "", [6, 9, 12], [0,0,0], '个定位XXXXO', showTitleArr);
  
  // 总和-大小,单双
  strTbl += crt_2face_com([ratedata.r72_0, ratedata.r71_0]
                         , [ratedata.r72_0total, ratedata.r71_0total]
                         , "", [72, 71], [0,0], '总和龙虎', showTitleArr2);
  // 龙虎
  strTbl += crt_2face_com([ratedata.r73_0]
                         , [ratedata.r73_0total]
                         , "", [73], [0], '龙虎和', showTitleArr3);
  $("#myDivTbl").html(strTbl);
}

// 双面盘口  
function show_2face_n5(_lotto_id, playtype, ratedata, _myHeader){
  var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += _myHeader;
  strTbl += crt_2face_a_S(ratedata.r62_0, ratedata.r62_0total, '0', 62, 0, '万千和数 OOXXX');
  strTbl += crt_2face_a_S(ratedata.r63_0, ratedata.r63_0total, '0', 63, 0, '万佰和数 OXOXX');
  strTbl += crt_2face_a_S(ratedata.r64_0, ratedata.r64_0total, '0', 64, 0, '万拾和数 OXXOX');
  strTbl += crt_2face_a_S(ratedata.r65_0, ratedata.r65_0total, '0', 65, 0, '万个和数 OXXXO');
  strTbl += crt_2face_a_S(ratedata.r66_0, ratedata.r66_0total, '0', 66, 0, '千佰和数 XOOXX');
  strTbl += crt_2face_a_S(ratedata.r67_0, ratedata.r67_0total, '0', 67, 0, '千拾和数 XOXOX');
  strTbl += crt_2face_a_S(ratedata.r68_0, ratedata.r68_0total, '0', 68, 0, '千个和数 XOXXO');
  strTbl += crt_2face_a_S(ratedata.r17_0, ratedata.r17_0total, '0', 17, 0, '佰拾和数 XXOOX');
  strTbl += crt_2face_a_S(ratedata.r18_0, ratedata.r18_0total, '0', 18, 0, '佰个和数 XXOXO');
  strTbl += crt_2face_a_S(ratedata.r19_0, ratedata.r19_0total, '0', 19, 0, '拾个和数 XXXOO');
  $("#myDivTbl").html(strTbl);
}

// 一字盘势  
function show_r1p(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += _myHeader;
  strTbl += crt_0To9(ratedata.r1_0, ratedata.r1_0total, "", 1, 0, '佰定位OXX');
  strTbl += crt_0To9(ratedata.r2_0, ratedata.r2_0total, "", 2, 0, '拾定位XOX');
  strTbl += crt_0To9(ratedata.r3_0, ratedata.r3_0total, "", 3, 0, '个定位XXO');
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}

function show_r1p_n5(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += _myHeader;
  strTbl += crt_0To9(ratedata.r69_0, ratedata.r69_0total, "", 69, 0, '万定位OXX');
  strTbl += crt_0To9(ratedata.r70_0, ratedata.r70_0total, "", 70, 0, '千定位OXX');
  strTbl += crt_0To9(ratedata.r1_0, ratedata.r1_0total, "", 1, 0, '佰定位OXX');
  strTbl += crt_0To9(ratedata.r2_0, ratedata.r2_0total, "", 2, 0, '拾定位XOX');
  strTbl += crt_0To9(ratedata.r3_0, ratedata.r3_0total, "", 3, 0, '个定位XXO');
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}                     

// 二字定位  
function show_r2p(_lotto_id, playtype, ratedata, myHeader){
  
  var strTbl = "";
  var i = 0;
  var bid = $("form#frmMenu input#bid").val();
  var btnArr = [14,15,16];
  var btnTitleArr = ['佰拾定位OOX', '佰个定位OXO', '拾个定位XOO'];
  var btnVal = "";
  var btnTitleVal = "";
  var classEND = "";
  // 切换按钮
  strTbl += "<div id='chgBtnGroup'>";
  for(i = 0; i < 3; i++){
    btnVal = btnArr[i];
    btnTitleVal = btnTitleArr[i];
    if(btnVal == bid){ classEND = "d"; }
    else{ classEND = ""; } 
    strTbl += "<input type='button' id='chgr" +  btnArr[i] + "' onclick='javascript:chgBid([" + btnVal + "])' class='btnchoice" + classEND + "' value='" + btnTitleVal + "' />";
  }
  strTbl += "</div>";
  
  // 开将画表格
  strTbl += "<table class='tblMy3D' width='100%' >";
  switch(bid){
    case '14': strTbl += crt_2p(ratedata.r14_0, ratedata.r14_0total, "", 14, 0, '佰拾定位OOX', 20); break;
    case '15': strTbl += crt_2p(ratedata.r15_0, ratedata.r15_0total, "", 15, 0, '佰个定位OXO', 20); break;
    case '16': strTbl += crt_2p(ratedata.r16_0, ratedata.r15_0total, "", 16, 0, '拾个定位XOO', 20); break;
    default: $("#myDivTbl").text('error -999'); return false;
  }
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
  
}

// 二字组合  
function show_r2(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  strTbl += "<table class='tblMy3D' width='100%' >";  
  strTbl += crt_2p(ratedata.r13_0, ratedata.r13_0total, "", 13, 0, '二字不定位', 11);
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}
function show_r2_n5(_lotto_id, playtype, ratedata, myHeader){
   var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += "<tr class='td0 bgClc_12'><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr>'";
  // 其它 - 前中后
  strTbl += crt_0To5(ratedata.r76_2, ratedata.r76_2total, "", 76, 2, '前三其它');
  strTbl += crt_0To5(ratedata.r76_1, ratedata.r76_1total, "", 76, 1, '中三其它');
  strTbl += crt_0To5(ratedata.r76_0, ratedata.r76_0total, "", 76, 0, '后三其它');
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}
function show_nn(_lotto_id, playtype, ratedata, myHeader){
   var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += "<tr class='td0 bgClc_12'><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr>'";
  strTbl += crt_0To99(ratedata.r74_0, ratedata.r74_0total, "", 74, 0, '牛牛',new Array("牛1","牛2","牛3","牛4","牛5","牛6","牛7","牛8","牛9","牛牛","牛大","牛小","无牛","牛单","牛双"));
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}
function show_sh(_lotto_id, playtype, ratedata, myHeader){
   var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += "<tr class='td0 bgClc_12'><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr>'";
  strTbl += crt_0To99(ratedata.r75_0, ratedata.r75_0total, "", 75, 0, '梭哈',new Array("五条","四条","葫芦","顺子","三条","两对","单对","散号"));
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}
// 二字和数  
function show_r2a(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  
  var i = 0;
  var bid = $("form#frmMenu input#bid").val();
  var btnArr = ['36,39','37,40','38,41'];
  var btnTitleArr = ['佰拾和数OOX', '佰个和数OXO', '拾个和数XOO'];
  var btnVal = "";
  var btnTitleVal = "";
  var classEND = "";
  var showId = 0;
  var showTitle = "";
  // 切换按钮
  strTbl += "<div id='chgBtnGroup'>";
  for(i = 0; i < 3; i++){
    btnVal = btnArr[i];
    btnTitleVal = btnTitleArr[i];
    if(btnVal == bid){ classEND = "d";  showId = i;}
    else{ classEND = ""; } 
    strTbl += "<input type='button' onclick='javascript:chgBid([" + btnVal + "])' class='btnchoice" + classEND + "' value='" + btnTitleVal + "' />";
  }
  showTitle = btnTitleArr[showId];
  strTbl += "</div>";
  strTbl += "<table class='tblMy3D' width='100%' >";
  strTbl += "<caption class='td0 bgClc_" + myGlobalVal.gametype + "'>" + showTitle + "</caption>";
  strTbl += myHeader;
  switch(showId){
    case 0:
      strTbl += crt_2p_a_0To18(ratedata.r36_0, ratedata.r36_0total, "", 36, 0, showTitle);
      strTbl += myHeader;
      strTbl += crt_a_0To9(ratedata.r39_0, ratedata.r39_0total, "", 39, 0, showTitle, "尾");
      break;
    case 1:
      strTbl += crt_2p_a_0To18(ratedata.r37_0, ratedata.r37_0total, "", 37, 0, showTitle);
      strTbl += myHeader;
      strTbl += crt_a_0To9(ratedata.r40_0, ratedata.r40_0total, "", 40, 0, showTitle, "尾");
      break;
    case 2:
      strTbl += crt_2p_a_0To18(ratedata.r38_0, ratedata.r38_0total, "", 38, 0, showTitle);
      strTbl += myHeader;
      strTbl += crt_a_0To9(ratedata.r41_0, ratedata.r41_0total, "", 41, 0, showTitle, "尾");
      break;
    default: $("#myDivTbl").text('error -998'); return false;
  }
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}

// 三字定位  
// 复式组合
function show_r3p(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  var sTitle = "";
  var oObj = "";
  var bettype = 21;
  if( playtype == 'rcmp' ){ 
    sTitle = "复式组合";
    oObj = ratedata.r35_0;
    oObj_total = ratedata.r35_0total;
    bettype = 35;
  }else{
    sTitle = "三字定位(佰拾个定位)";
    oObj = ratedata.r21_0;
    oObj_total = ratedata.r21_0total;
    bettype = 21;
  }
  strTbl += "<table class='tblMy3D' width='100%' >";
  strTbl += crt_2p(oObj, oObj_total, "", bettype, 0, sTitle, 20);
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}

// 三字组合  
function show_r3(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  strTbl += "<table class='tblMy3D' width='100%' >";
  strTbl += crt_2p(ratedata.r20_0, ratedata.r20_0total, "", 20, 0, '三字组合(三字不定位)', 22);
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}
// 三字组合5 码版
function show_r3_n5(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  var subid = $("form#frmMenu input#subid").val();
  
  strTbl += crt_btnSubid(subid, '三字不定位');
  strTbl += "<table class='tblMy3D' width='100%' >";
  switch(subid){
    case '0': strTbl += crt_2p(ratedata.r20_0, ratedata.r20_0total, "", 20, 0, '后三◎三字组合(三字不定位)', 22); break;
    case '1': strTbl += crt_2p(ratedata.r20_1, ratedata.r20_1total, "", 20, 1, '中三◎三字组合(三字不定位)', 22); break;
    case '2': strTbl += crt_2p(ratedata.r20_2, ratedata.r20_2total, "", 20, 2, '前三◎三字组合(三字不定位)', 22); break;
    default: return;
  }
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}

// 三字和数  
function show_r3a(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  strTbl += "<table class='tblMy3D' width='990' >";
  strTbl += "<caption class='td0 bgClc_" + myGlobalVal.gametype + "'>三字和数</caption>";
  strTbl += myHeader;
  strTbl += crt_3_a(ratedata.r42_0, ratedata.r42_0total, "", 42, 0, '百拾个和数OOO');
  strTbl += myHeader;
  strTbl += crt_a_0To9(ratedata.r43_0, ratedata.r43_0total, "", 43, 0, '佰拾个和数尾数OOO', "尾");
  $("#myDivTbl").html(strTbl);
}

// 组选三   
// 组选六 
function show_g3(_lotto_id, playtype, ratedata, myHeader, g3Flag){
  var strTbl = "";
  var showArr = "";
  var j = 0;
  var i = 0;
  var oObj = "";
  var oObj_total = "";
  var addNum = 0;
  var sTitle = "";
  var setQuickUrl = "";
  if(g3Flag){
    showArr = [24, 25, 26, 27, 28, 29];
    addNum = 5;
    sTitle = "组选三";
  }else{
    showArr = [30, 31, 32, 33, 34];
    addNum = 4;
    sTitle = "组选六";
  }
  var dataLeng = showArr.length;
  strTbl += "<table style='border: 1px solid #c8c8c8;' width='100%'>";
  //strTbl += "<caption class='td0 bgClc_" + myGlobalVal.gametype + "'>" + sTitle + "</caption>";
  strTbl += "<tr class='title0 bgImg_" + myGlobalVal.gametype + "' id='titletype'>";
  for(i = 0; i < dataLeng; i++){
    j = i + addNum;
    setQuickUrl = " id='url_" +  showArr[i] + "_0'";
    if( j < 10 ) { strTbl += "<th "+ setQuickUrl +" class='titleTypeBtnClick'><input type='button' class='btnmin' value='-' />&nbsp;" + j + "&nbsp;<input type='button' class='btnplus' value='&Phi;' /></th>"; }
    else { strTbl += "<th>全包</th>"; }
  }
  strTbl += "</tr>";
  strTbl += "<tr>";
  
  for(i = 0; i < dataLeng; i++ ){
    oObj = eval("ratedata.r" + showArr[i] + "_0");
    oObj_total = eval("ratedata.r" + showArr[i] + "_0total");
    strTbl += "<td valign='top'>";
    strTbl += crt_g(oObj, oObj_total, "", showArr[i], 0, showArr[i]);
    strTbl += "</td>";
  }
  strTbl += "</tr></table>";
  $("#myDivTbl").html(strTbl);
}

function show_g3_n5(_lotto_id, playtype, ratedata, myHeader, g3Flag){
  var subid = $("form#frmMenu input#subid").val();
  var strTbl = "";
  var showArr = "";
  var j = 0;
  var i = 0;
  var oObj = "";
  var oObj_total = "";
  var addNum = 0;
  var sTitle = "";
  var subTitle = ['后三', '中三', '前三']
  if(g3Flag){
    showArr = [24, 25, 26, 27, 28, 29];
    addNum = 5;
    sTitle = "组选三";
  }else{
    showArr = [30, 31, 32, 33, 34];
    addNum = 4;
    sTitle = "组选六";
  }
  var dataLeng = showArr.length;
  
  strTbl += crt_btnSubid(subid, sTitle); // 显示前三 中三 后三 按钮
  strTbl += "<table style='border: 1px solid #c8c8c8;' width='100%' cellPadding='0'>";
  strTbl += "<caption class='td0 bgClc_" + myGlobalVal.gametype + "'>" +  subTitle[subid] + "◎" + sTitle + "</caption>";
  strTbl += "<tr class='title0 bgImg_" + myGlobalVal.gametype + "' id='titletype'>";
  for(i = 0; i < dataLeng; i++){
    j = i + addNum;
    setQuickUrl = " id='url_" +  showArr[i] + "_" + subid + "'";
    if( j < 10 ) { strTbl += "<th "+ setQuickUrl +" class='titleTypeBtnClick' ><input type='button' class='btnmin' value='-' />&nbsp;" + j + "&nbsp;<input type='button' class='btnplus' value='&Phi;' /></th>"; }
    else { strTbl += "<th>全包</th>"; }
  }
  strTbl += "</tr>";
  strTbl += "<tr>";
  
  for(i = 0; i < dataLeng; i++ ){
    oObj = eval("ratedata.r" + showArr[i] + "_" + subid);
    oObj_total = eval("ratedata.r" + showArr[i] + "_" + subid + "total");
    strTbl += "<td valign='top'>";
    strTbl += crt_g(oObj, oObj_total, "", showArr[i], subid, showArr[i]);
    strTbl += "</td>";
  }
  strTbl += "</tr></table>";
  $("#myDivTbl").html(strTbl);

}

// 一字过关  
function show_r1pass(_lotto_id, playtype, ratedata){
  var strTbl = "";
  strTbl += "<table class='tblMy3D' width='990'><caption class='td0 bgClc_" + myGlobalVal.gametype + "'>一字过关</caption><thead><tr class='td6'><th>类别</th><th>合计</th><th colspan='6'>佰</th><th colspan='6'>拾</th><th colspan='6'>个</th></tr></thead>";
  strTbl += "<tbody class='td2' align='center'>";
  strTbl += "<tr class='td6'><th class='td6' rowspan='4'>一字过关</th><th class='span3dall' rowspan='4'>0</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th> <th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr>";
  strTbl += crt_1pass(ratedata.r46_0, ratedata.r46_0total, "", 46, 0, '一字过关');
  strTbl += "</tbody></table>";
  $("#myDivTbl").html(strTbl);
}

// 跨度
function show_r1bs(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  strTbl += "<table class='tblMy3D' width='990'>";
  strTbl += "<caption class='td0 bgClc_" + myGlobalVal.gametype + "'>跨度</caption>";
  strTbl += myHeader;
  strTbl += crt_a_0To9(ratedata.r47_0, ratedata.r47_0total, "", 47, 0, "跨度", "");
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}
// 跨度 - 5码 前中后一起秀
function show_r1bs_n5(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  strTbl += "<table class='tblMy3D' width='990'>";
  strTbl += "<caption class='td0 bgClc_" + myGlobalVal.gametype + "'>跨度</caption>";
  strTbl += myHeader;
  strTbl += crt_a_0To9(ratedata.r47_2, ratedata.r47_2total, "", 47, 2, "前三◎跨度", "");
  strTbl += crt_a_0To9(ratedata.r47_1, ratedata.r47_1total, "", 47, 1, "中三◎跨度", "");
  strTbl += crt_a_0To9(ratedata.r47_0, ratedata.r47_0total, "", 47, 0, "后三◎跨度", "");
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}

// 其他
function show_r1o(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  strTbl += "<table class='tblMy3D' width='990'>";
  strTbl += "<caption class='td0 bgClc_" + myGlobalVal.gametype + "'>其他</caption>";
  strTbl += myHeader;
  strTbl += crt_o([ratedata.r48_0,ratedata.r49_0, ratedata.r50_0, ratedata.r51_0, ratedata.r52_0]
                  , [ratedata.r48_0total, ratedata.r49_0total, ratedata.r50_0total, ratedata.r51_0total, ratedata.r52_0total]
                  , "", [48, 49, 50, 51, 52], [0, 0, 0, 0, 0], "其他");
  strTbl += crt_a_0To9(ratedata.r53_0, ratedata.r53_0total, "", 53, 0, "准对", "");
  strTbl += crt_a_0To9(ratedata.r54_0, ratedata.r54_0total, "", 54, 0, "不出牌", "");
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}

// 全部      
function show_all(_lotto_id, playtype, ratedata){
  _playtype = playtype;
  var strTbl = "";
  $("#myDivTbl").html(strTbl);
}

/*******************************简易版 table***********************************/
// 双面盘&龙虎和
function show_r1_n5s(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += _myHeader_sr1;
  
  // 第 N 球-大小,单双
  var showTitleArr = ['单', '双', '大', '小'];
  var showTitleArr2 = ['总单', '总双', '总大', '总小'];
  var showTitleArr3 = ['龙', '虎', '和', ''];
  
  // 第一球-单双,大小
  strTbl += crt_2face_com([ratedata.r1_1 , ratedata.r2_1] 
                        , [ratedata.r1_1total, ratedata.r2_1total]
                        , "", [1,2], [1,1], '第一球', showTitleArr);

  // 第二球-单双,大小
  strTbl += crt_2face_com([ratedata.r1_2 , ratedata.r2_2]
                        , [ratedata.r1_2total, ratedata.r2_2total]
                        , "", [1,2], [2,2], '第二球', showTitleArr);
  
  // 第三球-单双,大小
  strTbl += crt_2face_com([ratedata.r1_3 , ratedata.r2_3]
                        , [ratedata.r1_3total, ratedata.r2_3total]
                        , "", [1,2], [3,3], '第三球', showTitleArr);

  // 第四球-单双,大小
  strTbl += crt_2face_com([ratedata.r1_4 , ratedata.r2_4]
                        , [ratedata.r1_4total, ratedata.r2_4total]
                        , "", [1,2], [4,4], '第四球', showTitleArr);
  
  // 第五球-单双,大小
  strTbl += crt_2face_com([ratedata.r1_5 , ratedata.r2_5]
                        , [ratedata.r1_5total, ratedata.r2_5total]
                        , "", [1,2], [5,5], '第五球', showTitleArr);
  
  // 总和-单双,大小
  strTbl += crt_2face_com([ratedata.r3_0, ratedata.r4_0]
                         , [ratedata.r3_0total, ratedata.r4_0total]
                         , "", [3, 4], [0,0], '总和', showTitleArr2);
  // 龙虎和
  strTbl += crt_2face_com([ratedata.r5_0]
                         , [ratedata.r5_0total]
                         , "", [5], [0], '龙虎和', showTitleArr3);
  $("#myDivTbl").html(strTbl);
}

// 定位
function show_r1p_n5s(_lotto_id, playtype, ratedata){
  var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += _myHeader_sr1p;
  strTbl += crt_0To9(ratedata.r0_1, ratedata.r0_1total, "", 0, 1, '第一球');
  strTbl += crt_0To9(ratedata.r0_2, ratedata.r0_2total, "", 0, 2, '第二球');
  strTbl += crt_0To9(ratedata.r0_3, ratedata.r0_3total, "", 0, 3, '第三球');
  strTbl += crt_0To9(ratedata.r0_4, ratedata.r0_4total, "", 0, 4, '第四球');
  strTbl += crt_0To9(ratedata.r0_5, ratedata.r0_5total, "", 0, 5, '第五球');
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}

// 其他
function show_r1os(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  strTbl += "<table class='tblMy3D' width='990'>";
  strTbl += _myHeader_sr1p;
  strTbl += crt_o(ratedata.r6_2, ratedata.r6_2total, "", 6, 2, "前三其他");
  strTbl += crt_o(ratedata.r6_1, ratedata.r6_1total, "", 6, 1, "中三其他");
  strTbl += crt_o(ratedata.r6_0, ratedata.r6_0total, "", 6, 0, "后三其他");
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}
/*******************************简易版 table***********************************/

// -----------------------------------------------------------------------------
// 按了玩法执行结果
// -----------------------------------------------------------------------------
function clickTitle(playtype){
 $("#myDivNow").empty();
 $("#myDivTblTop").empty();
 $("#myDivTbl").empty();
 _playtype = playtype;
 $("form#frmMenu input#playtypestr").val(playtype);
 if(playtype == 'r2p'){
  $("form#frmMenu input#bid").val("14");
 }else if(playtype == 'r2a'){
  $("form#frmMenu input#bid").val("36,39");
 }else{
  $("form#frmMenu input#bid").val("");
 }
 $("form#frmMenu input#subid").val("0");                       
 $("th.cbig").removeClass('cbig');
 $("th#myThBar" + playtype).addClass('cbig');
 // "r3"=>"r3","r3p"=>"r3p","rcmp"=>"rcmp"
 // 切换快选画面
 var str = "<table width='990' class='table0' cellPadding=5>";
 switch(playtype){
    case 'r1':
	case 'r2':
	case 'nn':
	case 'sh':
      str += "<tr class=td2><td align=right>" + crt_divBtnAddVal(false) + "</td></tr>";
      str += "</table>";
      $("#myDivNow").html(str);
      $("form#frmMenu input:hidden#order").val("2");
      break;
    case 'r2f':
      str += "<tr class=td2><td align=center>" + crt_chkhint() + "</td><td align=right>" + crt_divBtnAddVal(false) + "</td></tr>";
      str += "</table>";
      $("#myDivNow").html(str);
      $("form#frmMenu input:hidden#order").val("2");
      break;
    case 'r1p': str += "<tr class=td2><td align=left>" + crt_divBtnQuick01(1) + "</td><td align=right>" + crt_divBtnAddVal(true) + "</td></tr>";
      str += "</table>";
      $("#myDivNow").html(str);
      $("form#frmMenu input:hidden#order").val("2");

      // 快选按钮 - 0,1,2,3...
      $("#divBtnQuick01 span").click(function(){  
        var addVal = $(this).text();
        $("#divBtnQuick01 input#iptQuick01Val").val(addVal);  // 存放快选号码
        $("#divBtnQuick01 span").removeClass("btnchoiced").addClass("btnchoice");
        $(this).removeClass("btnchoice").addClass("btnchoiced");
      });
      // + - 动作按钮 (根据快选号码)
      $("#divBtnAddVal input:button[class^=btn]").click(function(){
        var myVal = $("#divBtnQuick01 input#iptQuick01Val").val();
        var mp = "";
        if(myVal != ""){
          mp = $(this).attr("class").substr(3,1);
          $("form#frmMenu input#actionNum").val(myVal);         // 资料转移
          if(myGlobalVal.simple){
            $("form#frmMenu input#actionBettype").val("0_1,0_2,0_3,0_4,0_5");  // 简易版定位
          }
          else{
            if(myGlobalVal.jsFuname){
              $("form#frmMenu input#actionBettype").val("1,2,3,69,70");  // 5码加上万千定位
            }else{
              $("form#frmMenu input#actionBettype").val("1,2,3");        // 资料设定 991014去除不定位 1129 加回不定位 20110519去除不定位
            }
          }
          
          $("form#frmMenu input#actionMP").val(mp);             // 资料转移
          $("form#frmMenu input#addType").val("1");
          $("form#frmMenu input#method").val("2");
          $().setRateByXML(); // 更新赔率
        }else{
          alert('请先选择快选号码');
        }
      });
      break;
    case 'r2p':                                            
      str += "<tr class=td2><td align=left width='45%'>" + crt_divBtnQuick01(2) + "</td><td width='45%' align=left><span id='divBtnQuickArea'></span></td></tr>";
      str += "</table>";
      $("#myDivNow").html(str);
      $("form#frmMenu input:hidden#order").val("0");
      $("#divBtnQuick01 span").click(function(){
        var addVal = $(this).index();
        var addStr = "";
        switch(addVal){
          case 0:
          addStr = "00,11,22,33,44,55,66,77,88,99";
          break;
          case 1:
          addStr = "01,02,03,04,05,06,07,08,09,10,12,13,14,15,16,17,18,19,20,21,23,24,25,26,27,28,29,30,31,32,34,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,56,57,58,59,60,61,62,63,64,65,67,68,69,70,71,72,73,74,75,76,78,79,80,81,82,83,84,85,86,87,89,90,91,92,93,94,95,96,97,98";
          break;
        }
        $("#divBtnQuick01 input#iptQuick01Val").val(addStr);  // 暂存点选号码
        $("#divBtnQuick01 span").removeClass("btnchoiced").addClass("btnchoice");
        $(this).removeClass("btnchoice").addClass("btnchoiced");
      });
      break;
    case 'r2a': str += "<tr class=td2><td align=center>" + crt_chkhint() + "</td><td align=right>" + crt_divBtnAddVal(false) + "</td></tr>";
      str += "</table>";
      $("#myDivNow").html(str);
      $("form#frmMenu input:hidden#order").val("2");
      break;
    case 'r3p':
    case 'rcmp':
    // 开将画表格
      str += "<tr class=td2><td align=left width='45%'>" + crt_divBtnQuick01(3) + "</td><td width='45%' align=left><span id='divBtnQuickArea'></span></td></tr>";
      str += "</table>";
      $("#myDivNow").html(str);
      $("form#frmMenu input:hidden#order").val("0");
       // 快选(号码)按钮 - 豹子 / 对对 / 一般 号码
      $("#divBtnQuick01 span").click(function(){
        var addVal = $(this).index();
        var addStr = "";
        switch(addVal){
          case 0:
          addStr = "000,111,222,333,444,555,666,777,888,999";
          break;
          case 1:
          addStr = "001,002,003,004,005,006,007,008,009,010,011,020,022,030,033,040,044,050,055,060,066,070,077,080,088,090,099,100,101,110,112,113,114,115,116,117,118,119,121,122,131,133,141,144,151,155,161,166,171,177,181,188,191,199,200,202,211,212,220,221,223,224,225,226,227,228,229,232,233,242,244,252,255,262,266,272,277,282,288,292,299,300,303,311,313,322,323,330,331,332,334,335,336,337,338,339,343,344,353,355,363,366,373,377,383,388,393,399,400,404,411,414,422,424,433,434,440,441,442,443,445,446,447,448,449,454,455,464,466,474,477,484,488,494,499,500,505,511,515,522,525,533,535,544,545,550,551,552,553,554,556,557,558,559,565,566,575,577,585,588,595,599,600,606,611,616,622,626,633,636,644,646,655,656,660,661,662,663,664,665,667,668,669,676,677,686,688,696,699,700,707,711,717,722,727,733,737,744,747,755,757,766,767,770,771,772,773,774,775,776,778,779,787,788,797,799,800,808,811,818,822,828,833,838,844,848,855,858,866,868,877,878,880,881,882,883,884,885,886,887,889,898,899,900,909,911,919,922,929,933,939,944,949,955,959,966,969,977,979,988,989,990,991,992,993,994,995,996,997,998";
          break;
          case 2:
          addStr = "NORMAL";
          break;
        }
        $("#divBtnQuick01 input#iptQuick01Val").val(addStr);  // 暂存点选号码
        $("#divBtnQuick01 span").removeClass("btnchoiced").addClass("btnchoice");
        $(this).removeClass("btnchoice").addClass("btnchoiced");
      });
      $("#myDivTblTop").html(crt_pGroup());
      loadFunR3p();
      break;
    case 'r3': 
      str += "<tr class=td2><td align=left width='45%'>" + crt_divBtnQuick01(3) + "</td><td width='45%' align=left><span id='divBtnQuickArea'></span></td></tr>";
      str += "<tr class=td2><td align=left colspan=3>" + crt_rdoQuickPair() + "</td></tr>";
      str += "</table>";  
      $("#myDivNow").html(str);
      $("#myDivTblTop").html(crt_btnGruopOrder());
      $("form#frmMenu input:hidden#order").val("0");
      // 快选(号码)按钮 - 豹子 / 对对 / 一般 号码
      $("#divBtnQuick01 span").click(function(){
        $("fieldset#fldQuickPair input:checkbox").removeAttr("checked").removeAttr("disabled");
        var addVal = $(this).index();
        var addStr = "";
        switch(addVal){
          case 0:
          addStr = "000,111,222,333,444,555,666,777,888,999";
          break;
          case 1:
          addStr = "001,002,003,004,005,006,007,008,009,011,022,033,044,055,066,077,088,099,112,113,114,115,116,117,118,119,122,133,144,155,166,177,188,199,223,224,225,226,227,228,229,233,244,255,266,277,288,299,334,335,336,337,338,339,344,355,366,377,388,399,445,446,447,448,449,455,466,477,488,499,556,557,558,559,566,577,588,599,667,668,669,677,688,699,778,779,788,799,889,899";
          break;
          case 2:
          addStr = "012,013,014,015,016,017,018,019,023,024,025,026,027,028,029,034,035,036,037,038,039,045,046,047,048,049,056,057,058,059,067,068,069,078,079,089,123,124,125,126,127,128,129,134,135,136,137,138,139,145,146,147,148,149,156,157,158,159,167,168,169,178,179,189,234,235,236,237,238,239,245,246,247,248,249,256,257,258,259,267,268,269,278,279,289,345,346,347,348,349,356,357,358,359,367,368,369,378,379,389,456,457,458,459,467,468,469,478,479,489,567,568,569,578,579,589,678,679,689,789";
          break;
        }
        $("#divBtnQuick01 input#iptQuick01Val").val(addStr);  // 暂存点选号码
        $("#divBtnQuick01 span").removeClass("btnchoiced").addClass("btnchoice");
        $(this).removeClass("btnchoice").addClass("btnchoiced");
      }); 
      
      // 全选
      $("fieldset#fldQuickPair input:checkbox#chkCheckAll").click(function(){
        if($(this).attr("checked")){
          $("fieldset#fldQuickPair input:checkbox[id!=chkCheckAll]").attr("checked","checked").attr("disabled","true");
        }else{
          $("fieldset#fldQuickPair input:checkbox").removeAttr("checked").removeAttr("disabled");
        }
      });
      
      // 组三 / 组六 转直
      $("fieldset#fldQuickPair input").click(function(){
        $("td#divBtnQuick01 span").removeClass("btnchoiced").addClass("btnchoice");
        var addStr = "";
        $("#divBtnQuick01 input#iptQuick01Val").val(addStr);
        var getTypeVal = $("fieldset#fldQuickPair input:radio:checked").val();
        var addArr = new Array();
        var tempI = 0;
        var chkValArr = new Array();
        chkValArr[0] = new Array("001","002","003","004","005","006","007","008","009","011","022","033","044","055","066","077","088","099","112","113","114","115","116","117","118","119","122","133","144","155","166","177","188","199","223","224","225","226","227","228","229","233","244","255","266","277","288","299","334","335","336","337","338","339","344","355","366","377","388","399","445","446","447","448","449","455","466","477","488","499","556","557","558","559","566","577","588","599","667","668","669","677","688","699","778","779","788","799","889","899");
        chkValArr[1] = new Array("012","013","014","015","016","017","018","019","023","024","025","026","027","028","029","034","035","036","037","038","039","045","046","047","048","049","056","057","058","059","067","068","069","078","079","089","123","124","125","126","127","128","129","134","135","136","137","138","139","145","146","147","148","149","156","157","158","159","167","168","169","178","179","189","234","235","236","237","238","239","245","246","247","248","249","256","257","258","259","267","268","269","278","279","289","345","346","347","348","349","356","357","358","359","367","368","369","378","379","389","456","457","458","459","467","468","469","478","479","489","567","568","569","578","579","589","678","679","689","789");
        var chkNumArr = new Array();
        var tempI = 0;
        var chkFlag =false; var chkFlag10=false;var chkFlag11=false;var chkFlag12=false;var chkFlag13=false;
        $("fieldset#fldQuickPair input:checkbox:checked").each(function(idx){
            tempI = $(this).val();
            switch(tempI){
              case "chkAll": addArr = chkValArr[getTypeVal];return false;break;
              case "10":chkFlag10=true;break;
              case "11":chkFlag11=true;break;
              case "12":chkFlag12=true;break;
              case "13":chkFlag13=true;break;
              default:
              chkNumArr.push(tempI);
              break;
            }
        });
        if(chkNumArr.length > 0){
          chkFlag = true;
          var patt1 = new RegExp("["+chkNumArr.join(",")+"]");
        }
          
        var chkArr = new Array();
        for(idx in chkValArr[getTypeVal]){
          addThreeNum = $().addThreeNum(chkValArr[getTypeVal][idx]);
          if(chkFlag && chkValArr[getTypeVal][idx].match(patt1)){
            addArr.push(chkValArr[getTypeVal][idx]);
          }else if(chkFlag10 && (addThreeNum % 2 == 1)){
            addArr.push(chkValArr[getTypeVal][idx]);
          }else if(chkFlag11 && (addThreeNum % 2 == 0)){
            addArr.push(chkValArr[getTypeVal][idx]);
          }else if(chkFlag12 && (addThreeNum>13)){
            addArr.push(chkValArr[getTypeVal][idx]);
          }else if(chkFlag13 && (addThreeNum<14)){
            addArr.push(chkValArr[getTypeVal][idx]);
          }
        }
        addStr = addArr.join(",");
        $("#divBtnQuick01 input#iptQuick01Val").val(addStr);  // 暂存点选号码
      });
      // 前110名勾选
      $("#btnGruopOrder input:radio").click(function(){
        var valSlc = $("#btnGruopOrder input:radio:checked").index();
        if(valSlc == 0){
          $("form#frmMenu input:hidden#order").val("0");
        }else{
          $("form#frmMenu input:hidden#order").val("2");
        }
        $("input#btnReflash").click();
      });
     
      $("#btnGruopOrder input:radio:eq(0)").click();
      break;
    case 'r3a': str += "<tr class=td2><td align=center>" + crt_chkhint() + "</td><td align=right>" + crt_divBtnAddVal(false) + "</td></tr>";       str += "</table>";
      $("#myDivNow").html(str);
      $("form#frmMenu input:hidden#order").val("2");
      break;
    case 'g3': str += "<tr class=td2><td align=left>" + crt_divBtnQuick01(1) + "</td><td align=right>" + crt_divBtnAddVal(true) + "</td></tr>";
      str += "</table>";
      $("#myDivNow").html(str);
      $("form#frmMenu input:hidden#order").val("2");
      // 快选(号码)按钮 - 0,1,2,3...
      $("#divBtnQuick01 span").click(function(){
        var addVal = $(this).text();
        $("#divBtnQuick01 input#iptQuick01Val").val(addVal);  // 暂存点选号码
        $("#divBtnQuick01 span").removeClass("btnchoiced").addClass("btnchoice");
        $(this).removeClass("btnchoice").addClass("btnchoiced");
      });
      // + - 动作按钮 (根据快选号码)
      $("#divBtnAddVal input:button[class^=btn]").click(function(){
        var myVal = $("#divBtnQuick01 input#iptQuick01Val").val();
        var mp = "";
        if(myVal != ""){
          var subid = $("form#frmMenu input#subid").val();
          mp = $(this).attr("class").substr(3,1);
          $("form#frmMenu input#actionNum").val(myVal);             // 资料转移
          $("form#frmMenu input#actionBettype").val("24,25,26,27,28"); // 资料设定
          $("form#frmMenu input#actionMP").val(mp);                 // 资料转移
          $("form#frmMenu input#addType").val("1");
          $("form#frmMenu input#method").val("2");
          $("form#frmMenu input#subid").val(subid);
          $().setRateByXML(); // 更新赔率
        }else{
          alert('请先选择快选号码');
        }
      });
      break;
    case 'g6': str += "<tr class=td2><td align=left>" + crt_divBtnQuick01(1) + "</td><td align=right>" + crt_divBtnAddVal(true) + "</td></tr>"; 
      str += "</table>";
      $("#myDivNow").html(str);
      $("form#frmMenu input:hidden#order").val("2");
      // 快选(号码)按钮 - 0,1,2,3...
      $("#divBtnQuick01 span").click(function(){
        var addVal = $(this).text();
        $("#divBtnQuick01 input#iptQuick01Val").val(addVal);  // 暂存点选号码
        $("#divBtnQuick01 span").removeClass("btnchoiced").addClass("btnchoice");
        $(this).removeClass("btnchoice").addClass("btnchoiced");
      });
      // + - 动作按钮 (根据快选号码)
      $("#divBtnAddVal input:button[class^=btn]").click(function(){
        var myVal = $("#divBtnQuick01 input#iptQuick01Val").val();
        var mp = "";
        if(myVal != ""){
          var subid = $("form#frmMenu input#subid").val();
          mp = $(this).attr("class").substr(3,1);
          $("form#frmMenu input#actionNum").val(myVal);         // 资料转移
          $("form#frmMenu input#actionBettype").val("30,31,32,33,34"); // 资料设定
          $("form#frmMenu input#actionMP").val(mp);             // 资料转移
          $("form#frmMenu input#addType").val("1");
          $("form#frmMenu input#method").val("2");
          $("form#frmMenu input#subid").val(subid);
          $().setRateByXML(); // 更新赔率
        }else{
          alert('请先选择快选号码');
        }
      });
      break;
    case 'r1pass': str += "<tr class=td2><td align=right>" + crt_divBtnAddVal(false) + "</td></tr>";
          str += "</table>";
          $("#myDivNow").html(str);
          $("form#frmMenu input:hidden#order").val("2");
          break;
    case 'r1bs': str += "<tr class=td2><td align=right>" + crt_divBtnAddVal(false) + "</td></tr>";
          str += "</table>";
      $("#myDivNow").html(str);
      $("form#frmMenu input:hidden#order").val("2");
    break;
    case 'r1o': str += "<tr class=td2><td align=right>" + crt_divBtnAddVal(false) + "</td></tr>";
          str += "</table>";
          $("#myDivNow").html(str);
          $("form#frmMenu input:hidden#order").val("2");
    break;
    default: str += "<tr><td>error</td></tr>"; $("#myDivNow").html(str); break;
 }
 // 有快速操盘的功能
 var quickBettypeStr = ",g3,g6,r1pass,r1o,r2f,";
 var playtypeTemp = "," + playtype + ",";
 if(quickBettypeStr.indexOf(playtypeTemp) < 0){
    // 有快速操盘功能
    //if(!myGlobalVal.simple){$('[ <font style="color:blue;font-weight:bold;">设定</font> -- <input type="button" value="快速变更赔率" class="colorBtnGray" id="btnRateQuickRecord" /> ]&nbsp;&nbsp;&nbsp;').appendTo("#myDivTblTop");}
    // 快速操盘
    // change rate of quick
    $("input:button#btnRateQuickRecord").click(function(){
      var playtypestr = $("form#frmMenu input#playtypestr").val();
      var showSubid = $("form#frmMenu input#subid").val();
      var sUrl = 'op.php?op=subsidary&fp=rateQuickRecord_3d&gametype=' + myGlobalVal.gametype + '&pagename=' + playtypestr + '&showSubid=' + showSubid ;
      
      if(playtypestr == 'r2p'){
        var subIDQ = $("form#frmMenu input#bid").val();
        //alert(subIDQ);
        sUrl += "&subIDQ=" + subIDQ;
      }else if(playtypestr == 'r2a'){
        var subIDQ = $("form#frmMenu input#bid").val();
        sUrl += "&subIDQ=" + subIDQ;
      } 
      $().createDiv(sUrl);
    });
 }
 
 $("input#btnReflash").click();
 
 // button of add value -- over page
 $("#divBtnAddVal span").click(function(){
   var addVal = $(this).text();
   $("input#addVal").val(addVal);
   $("#divBtnAddVal span").removeClass("btnchoiced").addClass("btnchoice");
   $(this).addClass("btnchoiced");
   $().setCookie('btnAddVal3DCK' +playtype ,$(this).index());
 });
  
  var btnAddVal3DCK = $().getCookie('btnAddVal3DCK' + playtype,12);
  $("#divBtnAddVal span:eq(" + btnAddVal3DCK + ")").click();
  show_divBtnAddVal("1_" + playtype);
}

// 三字组合 勾选画面
function crt_btnGruopOrder(){
 $("#frmMenu").css("margin-bottom", "0");
  var str = "";
  str = '<br /><span id="btnGruopOrder" class="msgBox-yellow">';
  str += '<label><input type="radio" value="0" name="pFlag" checked="checked" />前110名(输赢排序)</label>';
  str += '<label><input type="radio" value="1" name="pFlag" />号码(排序)000~234</label>';
  str += '<label><input type="radio" value="2" name="pFlag" />号码(排序)235~999</label>';
  str += '</span>';
  str += '<input type="hidden" name="listnum" value="110" />';
  return str;
}

// 三字定位、复式组合 勾选画面
function crt_pGroup(){
  $("#frmMenu").css("margin-bottom", "0");
  var strTbl = "";
  strTbl += "<label class='bgClc_" + myGlobalVal.gametype + "'><input type='checkbox' value='100' name='listnum2' id='listnum2' checked='true' />仅显示前100名(输赢排序)</label>";
  strTbl += "<div id='pGroup' class='bgClc_" + myGlobalVal.gametype + "' style='display:none;text-align:left'><span style='background-color:#feffcd;' id='ptypeGroup'>定位别(号码排序)：";
  strTbl += "<label><input type='radio' value='0' name='ptype' checked='checked' />佰</label>";
  strTbl += "<label><input type='radio' value='1' name='ptype' />拾</label>";
  strTbl += "<label><input type='radio' value='2' name='ptype' />个</label>";
  strTbl += "</span>&nbsp;&nbsp;&nbsp;";
  strTbl += "<span id='pnumGroup'>定位数：";
  strTbl += "<label><input type='radio' value='0' name='pnum' checked='checked' />0</label>";
  strTbl += "<label><input type='radio' value='1' name='pnum' />1</label>";
  strTbl += "<label><input type='radio' value='2' name='pnum' />2</label>";
  strTbl += "<label><input type='radio' value='3' name='pnum' />3</label>";
  strTbl += "<label><input type='radio' value='4' name='pnum' />4</label>";
  strTbl += "<label><input type='radio' value='5' name='pnum' />5</label>";
  strTbl += "<label><input type='radio' value='6' name='pnum' />6</label>";
  strTbl += "<label><input type='radio' value='7' name='pnum' />7</label>";
  strTbl += "<label><input type='radio' value='8' name='pnum' />8</label>";
  strTbl += "<label><input type='radio' value='9' name='pnum' />9</label>";
  strTbl += "</span></div>";
  strTbl += "<input type='hidden' name='pFlag' id='pFlag' value='0' />";
  strTbl += '<input type="hidden" name="listnum" value="100" />';
  return strTbl;
}

// 三字定位, 复式组合 画面专用function
function loadFunR3p(){
  // 前100名 勾选
  $("input:checkbox#listnum2").click(function(){
    $(this).attr("disabled","disabled");
    if($(this).attr("checked")){
      $("#pGroup").css("display", "none");
      $("form#frmMenu input:hidden#order").val("0");
      $("form#frmMenu input:hidden#pFlag").val("0");
    }else{
      $("#pGroup").css("display", "");
      $("form#frmMenu input:hidden#order").val("2");
      $("form#frmMenu input:hidden#pFlag").val("1");
    }
    $("input#btnReflash").click();
  });
  
  // change play type mode by click 
  $("span#ptypeGroup input:radio").add("span#pnumGroup input:radio").click(function(){
    $("input#btnReflash").click();
  });
  
}

// -----------------------------------------------------------------------------
// for quick rate
// -----------------------------------------------------------------------------

// complex to string
$.fn.val2str = function(){
   var tempStr = "";
   $(this).each(function(idx,ele){
    tempStr = tempStr + "" + $(ele).val();
  });
  return tempStr;
};

$.fn.fixstr2 = function(elevalue){
	
    var numv=elevalue-0;
    var sign=(numv>=0?1:-1); // Will give 1 for num=0
  	var numabs=numv*sign;
  	var naint=Math.floor(numabs);
  	var nacent=Math.round((numabs-naint)*100);
  	if (nacent>=100) {nacent=0; naint++;}
  	var nais=''+naint;
  	var nacs=(nacent<10?'0':'')+nacent;
  	if (naint+nacent==0) sign=1;
  	elevalue = (sign==1?'':'-')+nais+'.'+nacs;
    return elevalue;  
  
};

// get input box 0 to night
$.fn.getInput0To9 = function(betid, lastStr){
  $(this).empty();
  var strTemp = '';
  for(i = 0; i < 10; i++){
    strTemp += '<label><input type="checkbox" value="' + i +  '" id="zerotonight' + betid + "_" + i + '" name="zerotonight' + betid + '[]" />' + i + lastStr + '&nbsp;&nbsp;</label>';
  }
  $(this).html(strTemp);
};

// get input box 0~4,5,6...,14~18 to night
$.fn.getInputCToM = function(betid, s, m){
  $(this).empty();
  var strTemp = '';
  strTemp += '<label style="width:60px;"><input type="checkbox" value="' + s +  '" name="zerotonight' + betid + '[]" />0~' + s + '&nbsp;&nbsp;</label>';
  var tempI = 1;
  for(i = s+1; i < m; i++){
    strTemp += '<label style="width:60px;"><input type="checkbox" value="' + i +  '" name="zerotonight' + betid + '[]" />' + i + '&nbsp;&nbsp;</label>';
    tempI++;
    if((tempI % 5) == 0){ strTemp += "<br />";}
    
  }
  strTemp += '<label style="width:60px;"><input type="checkbox" value="' + i +  '" name="zerotonight' + betid + '[]" />' + i + '~' + ( i - 0 + s) + '&nbsp;&nbsp;</label>';
  $(this).html(strTemp);
};


// get the quick check
$.fn.getRadioQuick = function(betid, showArr){
  $(this).empty();
  var strTemp = '';
  for(idx in showArr){
    strTemp += '<label><input type="radio" value="' + idx + '" name="quicktype' + betid + '" class="rqr" />' + showArr[idx]  + '</label>&nbsp;&nbsp;';
  }
  $(this).html(strTemp);
};

// get the rar select
$.fn.getSelectQuick = function(betid, next, max, yclass){
  $(this).empty();
  var classTemp = '';
  var strTemp = '<select id="rqr_newRate' + betid + '">';
  //strTemp += '<option value="1">&Phi;</option>';
  strTemp += '<option value="0" selected class="littleY">0.00</option>';
  var str = 0 - next;
  for(i = str; i > max; i -= next){
    i = $().fixstr2(i);
    classTemp = (i % yclass == 0) ? 'class="littleY"' : "";
    strTemp += '<option value="' + i + '" ' + classTemp + ' >' + i + '</option>';
  }
  strTemp += '</select>';
  $(this).html(strTemp);
};

// get the rar select
$.fn.getR2Table = function(){
  $(this).empty();
  var strTemp = '';
  var strSubTemp = '';
  var subIDQTemp = '';
  strSubTemp = '<tr class="rqr_th"><td><input type="reset" value="' + rqr_myFont[2] + '" /></td>';
  for(i = 0; i < 10; i++){
    strSubTemp += '<td><label><input type="checkbox" name="rqr_getR2Header[]" value="' + i + '" /> ' + i + rqr_myFont[1] +'</label></td>';
  }
  strSubTemp += '</tr>';
  strTemp += strSubTemp;    // set the header td
  
  for(i = 0; i < 10; i++){
    strSubTemp = '<tr ><td class="rqr_th"><label><input type="checkbox" name="rqr_getR2TR[]" value="' + i + '" /> ' + i + rqr_myFont[0] + '</label></td>'; 
    for(j = 0; j < 10 ; j++){
      if(j >= i){
        subIDQTemp = i + '' + j;
        strSubTemp += '<td id="rqr_R2Tbl_' + subIDQTemp + '">' + subIDQTemp + '</td>';
      }else{
        strSubTemp += '<td>&nbsp;</td>';
      }
    }
    strSubTemp += '</tr>';
    strTemp += strSubTemp;    // set the header td
  }
  strTemp += '<tr><th class="rqr_th">' + rqr_myFont[8] + '</th><td colspan="10"><div align="left" id="rqr_r13select"></div></td></tr>';
  $(this).attr("class", "mytdcss");
  $(this).html(strTemp);
  $("input:checkbox[name='rqr_getR2Header[]']").add("input:checkbox[name='rqr_getR2TR[]']").click(function(){
    $().rqr_R2TblColor();
  });
  
  $("div#rqr_r13select").getSelectQuick("13", 0.05, -1.51, 0.5);
  $().initQuickRateR2();
};

$.fn.init_rqrFast = function(betstr, subIDQ){
  
  switch(betstr){
    case 'r1':
      $("div#rqr_r0").getInput0To9("0", "");
      $("div#rqr_r0radio").getRadioQuick("0", quicktypeArrA);
      $("div#rqr_r0select").getSelectQuick("0", 0.05, -1.01, 0.25);
      $("div#rqr_r0 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r0radio input:radio[value='none']");
      });
      $("div#rqr_r0radio input:radio").click(function(){
        $(this).chkQuickChkBox(0);
      });
      var btnArr = new Array();
      btnArr.push("0");
      $().initQuickRateA(btnArr);
      break;
      
    case 'r1p':
      $("div#rqr_r0").getInput0To9("0", "");
      $("div#rqr_r0radio").getRadioQuick("0",quicktypeArrA);
      $("div#rqr_r0select").getSelectQuick("0", 0.05, -1.01, 0.25);
      $("div#rqr_r0 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r0radio input:radio[value='none']");
      });
      $("div#rqr_r0radio input:radio").click(function(){
        $(this).chkQuickChkBox(0);
      });
       
      $("div#rqr_r1").getInput0To9("1", "");
      $("div#rqr_r1radio").getRadioQuick("1",quicktypeArrB);
      $("div#rqr_r1select").getSelectQuick("1", 0.5, -1.01, 0.1);
      $("div#rqr_r1 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r1radio input:radio[value='none']");
      });
      $("div#rqr_r1radio input:radio").click(function(){
        $(this).chkQuickChkBox(1);
      });
      
      $("div#rqr_r2").getInput0To9("2", "");
      $("div#rqr_r2radio").getRadioQuick("2",quicktypeArrB);
      $("div#rqr_r2select").getSelectQuick("2", 0.5, -1.01, 0.1);
      $("div#rqr_r2 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r2radio input:radio[value='none']");
      });
      $("div#rqr_r2radio input:radio").click(function(){
        $(this).chkQuickChkBox(2);
      });
      
      $("div#rqr_r3").getInput0To9("3", "");
      $("div#rqr_r3radio").getRadioQuick("3",quicktypeArrB);
      $("div#rqr_r3select").getSelectQuick("3", 0.5, -1.01, 0.1);
      $("div#rqr_r3 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r3radio input:radio[value='none']");
      });
      $("div#rqr_r3radio input:radio").click(function(){
        $(this).chkQuickChkBox(3);
      });
      
      var btnArr = new Array();
      btnArr.push("0", "1", "2", "3");
      $().initQuickRateA(btnArr);
      break;
  
    case 'r2p':
      $("div#rqr_r" + subIDQ + "_p2").getInput0To9(subIDQ + "_p2", "");
      $("div#rqr_r" + subIDQ + "_p2radio").getRadioQuick(subIDQ + "_p2", quicktypeArrB);
      $("div#rqr_r" + subIDQ + "_p2 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r" + subIDQ + "_p2radio input:radio[value='none']");
      });
      $("div#rqr_r" + subIDQ + "_p2radio input:radio").click(function(){
        $(this).chkQuickChkBox(subIDQ + "_p2");
      });
      
      $("div#rqr_r" + subIDQ + "_p1").getInput0To9(subIDQ + "_p1", "");
      $("div#rqr_r" + subIDQ + "_p1radio").getRadioQuick(subIDQ + "_p1", quicktypeArrB);
      $("div#rqr_r" + subIDQ + "_p1select").getSelectQuick(subIDQ + "_p1", 1, -5.01, 10);
      $("div#rqr_r" + subIDQ + "_p1 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r" + subIDQ + "_p1radio input:radio[value='none']");
      });
      $("div#rqr_r" + subIDQ + "_p1radio input:radio").click(function(){
        $(this).chkQuickChkBox(subIDQ + "_p1");
      });
                   
      $().initQuickRateR2P(subIDQ);
      break; 

    case 'r2':
      $("tbody#rqr_tbdList").getR2Table();
      break;
      
    case 'r2a':
      $("div#rqr_r" + subIDQ).getInputCToM(subIDQ, 4, 14)
      $("div#rqr_r" + subIDQ + "select").getSelectQuick(subIDQ, 0.05, -1.01, 0.25);
      $("div#rqr_r" + subIDQ + " input:checkbox").click(function(){
        $(this).chkLabelColor("");
      });
      $("div#rqr_r" + subIDQ + "radio input:radio").click(function(){
        $(this).chkQuickChkBox(subIDQ);
      });
      
      var subIDQ2 = subIDQ - 0 + 3;
      $("div#rqr_r" + subIDQ2).getInput0To9(subIDQ2, rqr_myFont[1]);
      $("div#rqr_r" + subIDQ2 + "radio").getRadioQuick(subIDQ2, quicktypeArrB);
      $("div#rqr_r" + subIDQ2 + "select").getSelectQuick(subIDQ2, 0.05, -0.26, 0.15);
      $("div#rqr_r" + subIDQ2 + " input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r" + subIDQ2 + "radio input:radio[value='none']");
      });
      $("div#rqr_r" + subIDQ2 + "radio input:radio").click(function(){
        $(this).chkQuickChkBox(subIDQ2);
      });
      var btnArr = new Array();
      btnArr.push(subIDQ, subIDQ2);
      $().initQuickRateA(btnArr);
      break;

    case 'r3p':
      $("div#rqr_r21_p3").getInput0To9("21_p3", "");
      $("div#rqr_r21_p3radio").getRadioQuick("21_p3", quicktypeArrB);
      $("div#rqr_r21_p3 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r21_p3radio input:radio[value='none']");
      });
      $("div#rqr_r21_p3radio input:radio").click(function(){
        $(this).chkQuickChkBox("21_p3");
      });
      
      $("div#rqr_r21_p2").getInput0To9("21_p2", "");
      $("div#rqr_r21_p2radio").getRadioQuick("21_p2", quicktypeArrB);
      $("div#rqr_r21_p2 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r21_p2radio input:radio[value='none']");
      });
       $("div#rqr_r21_p2radio input:radio").click(function(){
        $(this).chkQuickChkBox("21_p2");
      });
      
      $("div#rqr_r21_p1").getInput0To9("21_p1", "");
      $("div#rqr_r21_p1radio").getRadioQuick("21_p1", quicktypeArrB);
      $("div#rqr_r21_p1 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r21_p1radio input:radio[value='none']");
      });
       $("div#rqr_r21_p1radio input:radio").click(function(){
        $(this).chkQuickChkBox("21_p1");
      });
      
      $("div#rqr_r21_p1select").getSelectQuick("21_p1", 1, -20.1, 10);
      $().initQuickRateR3("21");
      break;

    case 'r3':
      $("div#rqr_r20_p3").getInput0To9("20_p3", "");
      $("div#rqr_r20_p3radio").getRadioQuick("20_p3", quicktypeArrB);
      $("div#rqr_r20_p3 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r20_p3radio input:radio[value='none']");
      });
      $("div#rqr_r20_p3radio input:radio").click(function(){
        $(this).chkQuickChkBox("20_p3");
      });
      
      $("div#rqr_r20_p2").getInput0To9("20_p2", "");
      $("div#rqr_r20_p2radio").getRadioQuick("20_p2", quicktypeArrB);
      $("div#rqr_r20_p2 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r20_p2radio input:radio[value='none']");
      });
      $("div#rqr_r20_p2radio input:radio").click(function(){
        $(this).chkQuickChkBox("20_p2");
      });
      
      $("div#rqr_r20_p1").getInput0To9("20_p1", "");
      $("div#rqr_r20_p1radio").getRadioQuick("20_p1", quicktypeArrB);
      $("div#rqr_r20_p1 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r20_p1radio input:radio[value='none']");
      });
      $("div#rqr_r20_p1radio input:radio").click(function(){
        $(this).chkQuickChkBox("20_p1");
      });
      
      $("div#rqr_r20_p1select").getSelectQuick("20_p1", 1, -20.1, 10);
      $().initQuickRateR3("20");
      break;
      
    case 'r3a':
      $("div#rqr_r42").getInputCToM(42, 6, 21)
      $("div#rqr_r42select").getSelectQuick(42, 0.1, -2.1, 0.5);
      $("div#rqr_r42 input:checkbox").click(function(){
        $(this).chkLabelColor("");
      });
      $("div#rqr_r42radio input:radio").click(function(){
        $(this).chkQuickChkBox("42");
      });
      
      $("div#rqr_r43").getInput0To9(43, rqr_myFont[1]);
      $("div#rqr_r43radio").getRadioQuick(43, quicktypeArrB);
      $("div#rqr_r43select").getSelectQuick(43, 0.01, -0.26, 0.05);
      $("div#rqr_r43 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r43radio input:radio[value='none']");
      });
      $("div#rqr_r43radio input:radio").click(function(){
        $(this).chkQuickChkBox("43");
      });
      var btnArr = new Array();
      btnArr.push("42", "43");
      $().initQuickRateA(btnArr);
      
      break;
    
    case 'rcmp':
      $("div#rqr_r35_p3").getInput0To9("35_p3", "");
      $("div#rqr_r35_p3radio").getRadioQuick("35_p3", quicktypeArrB);
      $("div#rqr_r35_p3 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r35_p3radio input:radio[value='none']");
      });
      $("div#rqr_r35_p3radio input:radio").click(function(){
        $(this).chkQuickChkBox("35_p3");
      });
      
      $("div#rqr_r35_p2").getInput0To9("35_p2", "");
      $("div#rqr_r35_p2radio").getRadioQuick("35_p2", quicktypeArrB);
      $("div#rqr_r35_p2 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r35_p2radio input:radio[value='none']");
      });
       $("div#rqr_r35_p2radio input:radio").click(function(){
        $(this).chkQuickChkBox("35_p2");
      });
      
      $("div#rqr_r35_p1").getInput0To9("35_p1", "");
      $("div#rqr_r35_p1radio").getRadioQuick("35_p1", quicktypeArrB);
      $("div#rqr_r35_p1 input:checkbox").click(function(){
        $(this).chkLabelColor("div#rqr_r35_p1radio input:radio[value='none']");
      });
       $("div#rqr_r35_p1radio input:radio").click(function(){
        $(this).chkQuickChkBox("35_p1");
      });
      
      $("div#rqr_r35_p1select").getSelectQuick("35_p1", 0.1, -2.1, 0.5);
      $().initQuickRateR3("35");
      break;
    
    case 'r1bs':
      $("div#rqr_r47").getInput0To9("47", "");
      $("div#rqr_r47radio").getRadioQuick("47",quicktypeArrB);
      $("div#rqr_r47select").getSelectQuick("47", 0.01, -1.01, 0.25);
      $("div#rqr_r47radio input:radio").click(function(){
        $(this).chkQuickChkBox("47");
      });
      var btnArr = new Array();
      btnArr.push("47");
      $().initQuickRateA(btnArr);
      
      break;
  }
};

$.fn.chkLabelColor = function(disChkStr){
  if($(this).attr("checked")){ $(this).parent("label").addClass("intCHK"); }
  else{ $(this).parent("label").removeClass("intCHK"); }
  if(disChkStr != "") $(disChkStr).attr("checked", true);
};

$.fn.chkQuickChkBox = function(betid){
  var chkN = $(this).val();
  var chkEDArr = new Array();
  $("input:checkbox[name='zerotonight" + betid + "[]']").attr("checked", false).parent("label").removeClass("intCHK");
  switch(chkN){
    case 'sd0':
      chkEDArr = new Array("1", "3", "5", "7", "9");
      break;
      
    case 'sd1':
      chkEDArr = new Array("0", "2", "4", "6", "8");
      break;
    
    case 'bs0':
      chkEDArr = new Array("5", "6", "7", "8", "9");
      break;
    
    case 'bs1':
      chkEDArr = new Array("0", "1", "2", "3", "4");
      break;
    
    case 'pc0':
      chkEDArr = new Array("1", "2", "3", "5", "7");
      break;
    
    case 'pc1':
      chkEDArr = new Array("0", "4", "6", "8", "9");
      break;
    
    case 'all':
      chkEDArr = new Array("0","1","2","3", "4","5", "6","7", "8", "9");
      break;
  }
  for (idx in chkEDArr){
    $("input:checkbox#zerotonight" + betid + "_" + chkEDArr[idx]).attr("checked", true).parent("label").addClass("intCHK");
  }

};

// quick change rate button init
$.fn.initQuickRateA = function(betIDArr){
  $("form#frmRqr input#btnChg").click(function(){
    var betID = "";
    for(idx in betIDArr){
      var myValArr = new Array();
      betID = betIDArr[idx];
      $("form#frmRqr div#rqr_r" + betID + " input:checkbox[name^='zerotonight']:checked").val(function(idx, ele){
        myValArr.push(ele);
        return ele;      
      });
      var myVal = myValArr.join(","); 
      var addVal = $("#rqr_newRate" + betID).val();
      var typeVal = "";
      var subid = $("form#frmMenu input#subid").val();
      if(myVal != ""){
        if(addVal < 0){ addVal = 0 - addVal; }
        mp = "m";
        if(subid > 0) betID = betID + '_' + subid;
        $("form#frmMenu input#actionNum").val(myVal);
        $("form#frmMenu input#actionBettype").val(betID);
        $("form#frmMenu input#actionMP").val(mp);
        $("form#frmMenu input#method").val("3");
        $("form#frmMenu input#addVal").val(addVal);
        $("form#frmMenu input#addType").val("1");
        $().setRateByXML();
      }else{
        //alert(_errorMsg[0]);
      }
    }
    $().closeMyDiv();    
  });  
}

// quick change rate button init -- FOR R2 P
$.fn.initQuickRateR2P = function(){
  var betId = $("input#subIDQ").val();
  $("tbody#rqr_tbdList").append("<tr><td></td><td><div id='tbdChgRateNum' style='word-break:break-all'></div></td></tr>");
  $("div[id^='rqr_r" + betId + "_p'] input:checkbox")
  .add("div[id^='rqr_r" + betId + "_p'] input:radio")
  .click(function(){
    var strTemp = $().getQ2Value(betId);
    if( strTemp ){
      $("div#tbdChgRateNum").text(strTemp.join(","));
    }else{
      $("div#tbdChgRateNum").text("");
    }
  });

  $("form#frmRqr input#btnChg").click(function(){
      var betID = $("input#subIDQ").val();
      var myValArr = $().getQ2Value(betID);
      if(myValArr == false){
       alert(rqr_myFont[6]);
       return false;
      } 
      var myVal = myValArr.join(",");
      var addVal = $("#rqr_newRate" + betID + "_p1").val();
      var typeVal = "";
      if(myVal != ""){
        var subid = $("form#frmMenu input#subid").val();
        if(subid > 0) betID = betID + '_' + subid;
        if(addVal < 0){ addVal = 0 - addVal; }
        mp = "m";
        $("form#frmMenu input#actionNum").val(myVal);
        $("form#frmMenu input#actionBettype").val(betID);
        $("form#frmMenu input#actionMP").val(mp);
        $("form#frmMenu input#method").val("3");
        $("form#frmMenu input#addVal").val(addVal);
        $("form#frmMenu input#addType").val("1");
        $().setRateByXML();
        $().closeMyDiv();
      }   
  });  
}

$.fn.getQ2Value = function(betID){
      var myValArrP1 = new Array();
      var myValArrP2 = new Array();
      var myValArr = new Array();
      $("form#frmRqr div#rqr_r" + betID + "_p1 input:checkbox[name^='zerotonight']:checked").val(function(idx, ele){
        myValArrP1.push(ele);
        return ele;      
      });
      if(myValArrP1.length < 1){ return false; } 
      $("form#frmRqr div#rqr_r" + betID + "_p2 input:checkbox[name^='zerotonight']:checked").val(function(idx, ele){
        myValArrP2.push(ele);
        return ele;
      });
      if(myValArrP2.length < 1){ return false; } 
      for(idx2 in myValArrP2){
        for(idx1 in myValArrP1){
          myValArr.push(myValArrP2[idx2] + "" + myValArrP1[idx1]);
        }
      }
      return myValArr;

};

// quick change rate button init -- FOR R2
$.fn.initQuickRateR2 = function(){
  $("form#frmRqr input#btnChg").click(function(){
      var betID = "13";
      var myValArr = new Array();
      
      $("input:checkbox[name='rqr_getR2Header[]']:checked").val(function(idx, ele){
          myele = ele - 0 + 1;
          for(i = 0; i < myele ; i++){
            strTemp = i + '' + ele;
            myValArr.push(strTemp);
          }
          return ele; 
      });

      $("input:checkbox[name='rqr_getR2TR[]']:checked").val(function(idx, ele){
         var srcStr = myValArr.toString();
         for(i = ele; i < 10 ; i++){
           strTemp = ele + '' + i;
           if(srcStr.search(strTemp) == -1){
              myValArr.push(strTemp);
           }
         }
         return ele; 
      });
      
      if(myValArr.length < 1){
        alert(rqr_myFont[6]);
        return false;
      } 
       
      var myVal = myValArr.join(",");
      var addVal = $("#rqr_newRate13").val();
      var typeVal = "";
      if(myVal != ""){
        if(addVal < 0){ addVal = 0 - addVal; }
        mp = "m";
        var subid = $("form#frmMenu input#subid").val();
        if(subid > 0) betID = betID + '_' + subid;
        $("form#frmMenu input#actionNum").val(myVal);
        $("form#frmMenu input#actionBettype").val(betID);
        $("form#frmMenu input#actionMP").val(mp);
        $("form#frmMenu input#method").val("3");
        $("form#frmMenu input#addVal").val(addVal);
        $("form#frmMenu input#addType").val("1");
        $().setRateByXML();
        $().closeMyDiv();
      }   
  });  
}

// quick change rate button init -- FOR R3 , R3P, RCMP
$.fn.initQuickRateR3 = function(betId){
  $("tbody#rqr_tbdList").append("<tr><td colspan='2'><div id='tbdChgRateNum' style='word-break:break-all'></div></td></tr>");
  $("div[id^='rqr_r" + betId + "_p'] input:checkbox")
  .add("div[id^='rqr_r" + betId + "_p'] input:radio")
  .click(function(){
    $("div#tbdChgRateNum").text($().getChkArr3RNumStr(betId));
  });
                         
  $("form#frmRqr input#btnChg").click(function(){
      var betID = betId;
      var myVal = $().getChkArr3RNumStr(betID);
      var addVal = $("#rqr_newRate" + betID + "_p1").val();
      var typeVal = "";
      if(myVal != ""){
        if(addVal < 0){ addVal = 0 - addVal; }
        var subid = $("form#frmMenu input#subid").val();
        if(subid > 0) betID = betID + '_' + subid;
        $("form#frmMenu input#actionNum").val(myVal);
        $("form#frmMenu input#actionBettype").val(betID);
        $("form#frmMenu input#actionMP").val("m");
        $("form#frmMenu input#method").val("3");
        $("form#frmMenu input#addVal").val(addVal);
        $("form#frmMenu input#addType").val("1");
        $().setRateByXML();
        $().closeMyDiv();
      }else{
        alert(rqr_myFont[6]);
      }   
  });  
}

// change the td color when header checkbox clicked
$.fn.rqr_R2TblColor = function(){
 var myValArrP1 = new Array();
 var myValArrP2 = new Array();
 var myValArr = new Array();
 var strTemp = '';
 $("td[id^='rqr_R2Tbl_']").css("background-color", "");     
 $("input:checkbox[name='rqr_getR2Header[]']:checked").val(function(idx, ele){
    myele = ele - 0 + 1;
    for(i = 0; i < myele ; i++){
      strTemp = i + '' + ele;
      $("td#rqr_R2Tbl_" + strTemp).css("background-color", "red");
    }
    return ele; 
 });

 $("input:checkbox[name='rqr_getR2TR[]']:checked").val(function(idx, ele){
    for(i = ele; i < 10 ; i++){
      strTemp = ele + '' + i;
      $("td#rqr_R2Tbl_" + strTemp).css("background-color", "red");
    }
    return ele; 
 });
 
};

// get the check box number for R3, R3P, RCMP
$.fn.getChkArr3RNumStr = function(betID){
  var myValArrP1 = new Array();
  var myValArrP2 = new Array();
  var myValArrP3 = new Array();
  var myValArr = new Array();
  var myValTempArr = new Array();
  var myValStrTemp = "";
  $("form#frmRqr div#rqr_r" + betID + "_p3 input:checkbox[name^='zerotonight']:checked").val(function(idx, ele){
    myValArrP3.push(ele);
    return ele;
  });
  if(myValArrP3.length < 1){
    return "";
  } 
  $("form#frmRqr div#rqr_r" + betID + "_p2 input:checkbox[name^='zerotonight']:checked").val(function(idx, ele){
    myValArrP2.push(ele);
    return ele;
  });
  if(myValArrP2.length < 1){
    return "";
  } 
  $("form#frmRqr div#rqr_r" + betID + "_p1 input:checkbox[name^='zerotonight']:checked").val(function(idx, ele){
    myValArrP1.push(ele);
    return ele;      
  });
  if(myValArrP1.length < 1){
    return "";
  } 
  
  switch(betID){
    case "20":  // r3
      for(idx3 in myValArrP3){
        for(idx2 in myValArrP2){
          for(idx1 in myValArrP1){
            myValTempArr = new Array();
            myValTempArr.push(myValArrP3[idx3], myValArrP2[idx2], myValArrP1[idx1]);
            myValTempArr.sort();
            myValStrTemp = myValTempArr.join("");
            myValArrStr = myValArr.toString();
            if(myValArrStr.search(myValStrTemp) == -1){
              myValArr.push(myValStrTemp);
            }
          }
        }
      }
      myValArr.sort();
      break;
      
    case "21":  // r3p
    case "35":  // RCMP
      for(idx3 in myValArrP3){
        for(idx2 in myValArrP2){
          for(idx1 in myValArrP1){
            myValArr.push(myValArrP3[idx3] + "" + myValArrP2[idx2] + "" + myValArrP1[idx1]);
          }
        }
      }
      break;
  }
  return myValArr.toString();

};




// -----------------------------------------------------------------------------
// for now page
// -----------------------------------------------------------------------------

$(function(){
  
  // the default value
  nowdate();
  countdown();
    // raterecord -- over page
  $("input:button#btnRateRecord").click(function(){
    showRateRecordPage(myGlobalVal.gametype, myGlobalVal.open)  
  });  
  
  // button of reload, just reflash rates instade of reload all page
  $("input#btnReflash").click(function(){ $("span#reflashtimeMin").text(myGlobalVal.reloadCK); $(this).getAjaxDataAuto(_playtype, __roundID);$("form#frmMenu input").attr("disabled","true"); });
  
  clickTitle(myGlobalVal.playtypestr);
  
});